{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# EARLY (FREQUENT) RIDERS ONLY"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Loading required package: data.table\n",
      "\n",
      "Loading required package: feather\n",
      "\n",
      "Loading required package: formula.tools\n",
      "\n"
     ]
    }
   ],
   "source": [
    "import_and_maybe_install <- function(pkgs){\n",
    "    missing_packages <- character(0)\n",
    "    for(pkg in pkgs){\n",
    "        tryCatch({\n",
    "            require(pkg, character.only=TRUE )\n",
    "        },warning=function(err){\n",
    "            missing_packages <<- c(missing_packages,pkg)\n",
    "        })\n",
    "    }\n",
    "    if(length(missing_packages)){\n",
    "            install.packages(missing_packages)\n",
    "            sapply(missing_packages, require, character.only=TRUE)\n",
    "    }\n",
    "    invisible(NULL)\n",
    "}\n",
    "import_and_maybe_install(c(\"data.table\", \"feather\", \"formula.tools\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "DATA_DIR <- \"~/connector/20200226/analytic_datasets\"\n",
    "\n",
    "commute_ride_data <- read_feather( file.path(DATA_DIR,\"commute_ride_data.feather\"))\n",
    "setDT(commute_ride_data)\n",
    "\n",
    "# FACTOR VARIABLES\n",
    "stopifnot(commute_ride_data[,class(fAid) == \"factor\"]) # rider id\n",
    "stopifnot(commute_ride_data[,class(fDate) == \"factor\"]) # date id\n",
    "\n",
    "route_field <- sprintf(\"route_%s_10_ride\",1:21)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### FILTER on EARLY RIDERS"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Number of Early Riders"
     ]
    },
    {
     "data": {
      "text/html": [
       "3908"
      ],
      "text/latex": [
       "3908"
      ],
      "text/markdown": [
       "3908"
      ],
      "text/plain": [
       "[1] 3908"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Full Data\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<table>\n",
       "<thead><tr><th scope=col>Records</th><th scope=col>Rides</th></tr></thead>\n",
       "<tbody>\n",
       "\t<tr><td>3354470</td><td>805199 </td></tr>\n",
       "</tbody>\n",
       "</table>\n"
      ],
      "text/latex": [
       "\\begin{tabular}{r|ll}\n",
       " Records & Rides\\\\\n",
       "\\hline\n",
       "\t 3354470 & 805199 \\\\\n",
       "\\end{tabular}\n"
      ],
      "text/markdown": [
       "\n",
       "| Records | Rides |\n",
       "|---|---|\n",
       "| 3354470 | 805199  |\n",
       "\n"
      ],
      "text/plain": [
       "  Records Rides \n",
       "1 3354470 805199"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Early riders only\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<table>\n",
       "<thead><tr><th scope=col>Records</th><th scope=col>Rides</th></tr></thead>\n",
       "<tbody>\n",
       "\t<tr><td>1792156</td><td>640522 </td></tr>\n",
       "</tbody>\n",
       "</table>\n"
      ],
      "text/latex": [
       "\\begin{tabular}{r|ll}\n",
       " Records & Rides\\\\\n",
       "\\hline\n",
       "\t 1792156 & 640522 \\\\\n",
       "\\end{tabular}\n"
      ],
      "text/markdown": [
       "\n",
       "| Records | Rides |\n",
       "|---|---|\n",
       "| 1792156 | 640522  |\n",
       "\n"
      ],
      "text/plain": [
       "  Records Rides \n",
       "1 1792156 640522"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "dates = commute_ride_data[,.N,keyby=.(date,fDate)]\n",
    "MAX_DATE = dates[15,date]\n",
    "\n",
    "early_riders = commute_ride_data[date <= MAX_DATE & did_ride,1,keyby=aid][,V1:=NULL]\n",
    "cat(\"Number of Early Riders\")\n",
    "early_riders[,.N]\n",
    "\n",
    "cat(\"Full Data\\n\")\n",
    "commute_ride_data[,.(Records=.N,Rides=sum(did_ride))]\n",
    "\n",
    "setkey(commute_ride_data,aid)\n",
    "commute_ride_data = commute_ride_data[early_riders]\n",
    "\n",
    "cat(\"Early riders only\\n\")\n",
    "commute_ride_data[,.(Records=.N,Rides=sum(did_ride))]\n",
    "\n",
    "#commute_ride_data[,1,aid][,.N]\n",
    "#commute_ride_data[(!SR520WBHOV) &  (!SR520EBHOV),.N]\n",
    "#commute_ride_data[(!SR520WBHOV) &  (!SR520EBHOV),1,aid][,.N]\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "# CALCULATE FAVORITE ROUTE\n",
    "commute_ride_data$favorite_route <- apply(\n",
    "    as.matrix(commute_ride_data[,sprintf(\"route_%s_10_ride\",1:21),with=FALSE]),\n",
    "    1,\n",
    "    function(x){\n",
    "        routes = which(x == max(x))\n",
    "        if(length(routes) == 1){\n",
    "            routes\n",
    "        }else{\n",
    "            sample(routes,1)\n",
    "        }\n",
    "    })\n",
    "\n",
    "commute_ride_data[, f_favorite_route:= as.factor(favorite_route) ]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Data Dictionary\n",
    "\n",
    "Each record represents one rider commute opportunty (rider / date / commute).\n",
    "\n",
    "**Note that** there is one record for each commute / data for every rider \n",
    "*After their first ride date*.  This is because the choice to ride (`did_ride`) \n",
    "is conditioned on the rider's history of riding, and which is not available \n",
    "on thier first ride.\n",
    "\n",
    "#### Identifiers\n",
    "* **aid**: Rider number (anonomyzed Numeric)\n",
    "* **fAid**: Rider number (anonomyzed Factor)\n",
    "* **date**: Date of the ride (as Date)\n",
    "* **fDate**: Date of the ride (as Factor)\n",
    "* **AfternoonId**: Function of Date, only true for Route 5\n",
    "\n",
    "#### Main outcome / predictor\n",
    "* **did_ride**: Did the rider ride on this date?\n",
    "* **imputed_new_buses**: The weighted average of the fraction of new busses \n",
    "     on the routes the rider took on the last (up to) 10 trips\n",
    "\n",
    "#### Time since last ride\n",
    "* **commutes_since_last_ride**: Number of commutes since rider's last ride (numeric; range 1 - 461)\n",
    "* **f_commutes_since_last_ride**: Number of commutes since rider's last ride (factor; range \"1\" - \"40+\")\n",
    "     \n",
    "#### Date based indicators\n",
    "* **SR520WBHOV**: SR 520 West Bound is open (Function of the date)\n",
    "* **SR520EBHOV**: SR 520 East Bound is open (Function of the date)\n",
    "* **I405HOV**: Is a 405 HOV is open (Function of the date )\n",
    "* **Route5Expansion**: Route 5 expanded (Function of Date )\n",
    "\n",
    "#### Features based on the rider's history\n",
    "* **route_X_10_ride** (e.g. `route_3_10_ride`):  Fraction of the rider's last 10 rides that were taken on route X\n",
    "* **is_peak_10_ride**: Fraction of the rider's last 10 rides that were taken **during peak traffic**\n",
    "* **IsESOther_10_ride**: Fraction of the rider's last 10 rides that were taken on **EastSide (other) routes**\n",
    "* **IsRouteSeattle_10_ride**: Fraction of the rider's last 10 rides that were taken on **Seattle Routes**\n",
    "* **Is405North_10_ride**: Fraction of the rider's last 10 rides that were taken on **I 405 North Routes**\n",
    "* **IsCoach_10_ride**: Fraction of the rider's last 10 rides that were taken on  **Coach (as opposed to shuttle) busses**\n",
    "* **first_stop_10_ride**: Fraction of the rider's last 10 rides that were taken from **the last AM stop**\n",
    "* **last_stop_10_ride**: Fraction of the rider's last 10 rides that were taken on  **the first AM stop**\n",
    "* **single_stop_10_ride**: Fraction of the rider's last 10 rides that were taken on **a Single Stop Route**\n",
    "* **vehicle_is_new_10_ride**: Fraction of the rider's last 10 rides that were taken on **a new vehicle**"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## A Handy Utility function for fitting models and gathering summary statistics"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "#' A cute little function for fitting a model and pulling out the headline statistics\n",
    "#'\n",
    "#' @param data A dataset for fitting the model\n",
    "#' @param model A number for identifying the model in a table (these second field in the \"coef\" output)\n",
    "#' @param lhs The left hand side of the model (as a string)\n",
    "#' @param predictors The effects of interested.  Specifically these are the effects that will be pulled out in the summary table\n",
    "#' @param adjust_for The fixed effects that will be included in the right hand side but not pulled out into the summar table\n",
    "#'\n",
    "#' @return A list containing the glm model (`$model`), and a matrix of interesting statistics from the\n",
    "#'       various models (`$coef`)\n",
    "\n",
    "fit_ridership_logit_models <- function(data,\n",
    "                                        model=1,\n",
    "                                        lhs=\"did_ride\",\n",
    "                                        predictors=\"new_fraction_10day\",\n",
    "                                        adjust_for=c(\"fDate\",route_field),# up to 231 levels\n",
    "                                        quick=FALSE,\n",
    "                                        boot.reps=1001,\n",
    "                                        granularity=\"\"){\n",
    "\n",
    "    # build and test the formula \n",
    "    (FMLA <- formula(paste(lhs,'~',paste(c(predictors,adjust_for),collapse=' + '))))\n",
    "    .updated = as.character(update(FMLA,~.))\n",
    "    if(length(.updated)>1){\n",
    "        .rhs = .updated[3]\n",
    "    }else{\n",
    "        .rhs = strsplit(as.character(update(FMLA,~.)),\" *~ *\")[[1]][2]\n",
    "    }\n",
    "    .terms = strsplit(.rhs,\" *\\\\+ *\")[[1]]\n",
    "    \n",
    "    \n",
    "    .vars = get.vars(rhs(FMLA))\n",
    "    if(any(! (.vars %in% names(data))))\n",
    "           stop(paste(\"missing variable: \",.vars[! (.vars %in% names(data))],collapse=\"\\\\n\"))\n",
    "           \n",
    "    if(any(!(predictors %in% .terms))){\n",
    "        cat(\"\\n===============================================\\n\")\n",
    "        cat(\"terms :\\n\")\n",
    "        cat(paste0(.terms,\"\\n\"))\n",
    "        cat(\"\\npredictors :\\n\")\n",
    "        cat(paste0(predictors[!(predictors %in% .terms)],\"\\n\"))\n",
    "        cat(\"\\n===============================================\\n\")\n",
    "        stop(\"Bad Predctors\")\n",
    "        \n",
    "    }    \n",
    "    \n",
    "    quick_N <- 5e5\n",
    "    if(quick & data[,.N] > quick_N)\n",
    "        data <- data[sample(.N,quick_N)]\n",
    "    \n",
    "\n",
    "    # FIT THE OLS MODELS\n",
    "    if(TRUE){\n",
    "        \n",
    "        (FMLA <- formula(paste(lhs,'~',paste(c(predictors,adjust_for),collapse=' + '))))\n",
    "        .lm0 <- lm(FMLA, data = data) # Useful for extracting the R-squared value\n",
    "        LM <- glm(FMLA, data = data) # required for the wild bootstrap\n",
    "    }else{\n",
    "        (FMLA_main <- formula(paste(lhs,'~',paste(c(predictors),collapse=' + '))))\n",
    "        (FMLA_fixed <- formula(paste('~',paste(adjust_for,collapse=' + '))))\n",
    "\n",
    "        # doesn't work (LM <- lm_robust(FMLA_main,  data = data, fixed = FMLA_fixed) )\n",
    "        (LM <- do.call(lm_robust,list(FMLA_main, data = data, fixed = FMLA_fixed,se_type=\"classical\") )) # I hate magic\n",
    "    }\n",
    "    \n",
    "    # SUMMARY OF THE OLS MODEL\n",
    "    cat(\"\\n===============================================\\n\")\n",
    "    cat(\"Model \",model,\":\")\n",
    "    cat(\"\\n===============================================\\n\")\n",
    "   \n",
    "    cat(\"\\n\\nCoefficients from Linear model (adjust_for effects omitted):\\n\")\n",
    "    \n",
    "    # catch the re-ordering of interaction terms introduced by the update(form,dev.new ~ .) call in cluster.wild.glm\n",
    "    tryCatch({\n",
    "        print(coef(summary(LM))[predictors,])    \n",
    "    },error = function(err){\n",
    "        model_coef = dimnames(coef(summary(LM)))[[1]]\n",
    "        cat(\"\\n=------------------------======================\\n\")\n",
    "            print(FMLA)\n",
    "            print(coef(summary(LM)))\n",
    "        cat(\"\\n=------------------------======================\\n\")\n",
    "        cat(\"Missing coefficients:\\n\",\n",
    "            predictors[! predictors %in% model_coef])\n",
    "        cat(\"\\n\\nAvailable coefficients:\\n\")\n",
    "        \n",
    "        print(model_coef)\n",
    "        stop(err)\n",
    "    })\n",
    "\n",
    "    # DO THE WILD BOOTSTRAP\n",
    "    # set.seed(10101)\n",
    "    # cl <-cluster.wild.glm(LM, dat = data, cluster = ~ factor(favorite_route), boot.reps = boot.reps, report=FALSE )\n",
    "\n",
    "    # MAKE THE PRETTY OUTPUT\n",
    "    # without doing the (slow) wild bootstrap\n",
    "    out <- cbind(model=model,\n",
    "                rbind(coef(summary(LM))[predictors,]),\n",
    "                # rbind(cl$ci[predictors,]),\n",
    "                r2= summary(.lm0)$r.squared,\n",
    "                N=data[,.N],\n",
    "                granularity=granularity)\n",
    "\n",
    "    rm(LM); gc() # alas...\n",
    "    # dimnames(out)[[1]] <- predictors\n",
    "    return(out)\n",
    "\n",
    "} "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Fit the Models for table 2\n",
    "* Pre 520 HOV data only"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "===============================================\n",
      "Model  1 :\n",
      "===============================================\n",
      "\n",
      "\n",
      "Coefficients from Linear model (adjust_for effects omitted):\n",
      "    Estimate   Std. Error      t value     Pr(>|t|) \n",
      "2.367577e-02 1.421739e-03 1.665268e+01 2.944742e-62 \n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<table>\n",
       "<thead><tr><th scope=col>model</th><th scope=col>Estimate</th><th scope=col>Std. Error</th><th scope=col>t value</th><th scope=col>Pr(&gt;|t|)</th><th scope=col>r2</th><th scope=col>N</th><th scope=col>granularity</th></tr></thead>\n",
       "<tbody>\n",
       "\t<tr><td>1                           </td><td>0.0236757651855375          </td><td>0.00142173916370504         </td><td>16.6526784869867            </td><td>2.94474161476437e-62        </td><td>0.276629897089897           </td><td>1104348                     </td><td>rider/date/commute [Pre-HOV]</td></tr>\n",
       "</tbody>\n",
       "</table>\n"
      ],
      "text/latex": [
       "\\begin{tabular}{llllllll}\n",
       " model & Estimate & Std. Error & t value & Pr(>\\textbar{}t\\textbar{}) & r2 & N & granularity\\\\\n",
       "\\hline\n",
       "\t 1                                & 0.0236757651855375               & 0.00142173916370504              & 16.6526784869867                 & 2.94474161476437e-62             & 0.276629897089897                & 1104348                          & rider/date/commute {[}Pre-HOV{]}\\\\\n",
       "\\end{tabular}\n"
      ],
      "text/markdown": [
       "\n",
       "| model | Estimate | Std. Error | t value | Pr(>|t|) | r2 | N | granularity |\n",
       "|---|---|---|---|---|---|---|---|\n",
       "| 1                            | 0.0236757651855375           | 0.00142173916370504          | 16.6526784869867             | 2.94474161476437e-62         | 0.276629897089897            | 1104348                      | rider/date/commute [Pre-HOV] |\n",
       "\n"
      ],
      "text/plain": [
       "     model Estimate           Std. Error          t value         \n",
       "[1,] 1     0.0236757651855375 0.00142173916370504 16.6526784869867\n",
       "     Pr(>|t|)             r2                N      \n",
       "[1,] 2.94474161476437e-62 0.276629897089897 1104348\n",
       "     granularity                 \n",
       "[1,] rider/date/commute [Pre-HOV]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "(table2_model1_pre_HOV = fit_ridership_logit_models(data = commute_ride_data[(!SR520WBHOV) &  (!SR520EBHOV)],\n",
    "                            predictors=c(\"imputed_new_buses\"),\n",
    "                            adjust_for=c(\"f_favorite_route\", \"f_commutes_since_last_ride\"),\n",
    "                            model=1,\n",
    "                            granularity=\"rider/date/commute [Pre-HOV]\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "===============================================\n",
      "Model  2 :\n",
      "===============================================\n",
      "\n",
      "\n",
      "Coefficients from Linear model (adjust_for effects omitted):\n",
      "                                            Estimate  Std. Error  t value\n",
      "imputed_new_buses                        0.020381662 0.002117618 9.624808\n",
      "imputed_new_buses:IsRouteSeattle_10_ride 0.005938427 0.002829200 2.098977\n",
      "                                             Pr(>|t|)\n",
      "imputed_new_buses                        6.294882e-22\n",
      "imputed_new_buses:IsRouteSeattle_10_ride 3.581912e-02\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<table>\n",
       "<thead><tr><th></th><th scope=col>model</th><th scope=col>Estimate</th><th scope=col>Std. Error</th><th scope=col>t value</th><th scope=col>Pr(&gt;|t|)</th><th scope=col>r2</th><th scope=col>N</th><th scope=col>granularity</th></tr></thead>\n",
       "<tbody>\n",
       "\t<tr><th scope=row>imputed_new_buses</th><td>2                           </td><td>0.0203816624978698          </td><td>0.0021176175266326          </td><td>9.62480818256184            </td><td>6.2948821992348e-22         </td><td>0.276632783066185           </td><td>1104348                     </td><td>rider/date/commute [Pre-HOV]</td></tr>\n",
       "\t<tr><th scope=row>imputed_new_buses:IsRouteSeattle_10_ride</th><td>2                           </td><td>0.00593842727766852         </td><td>0.00282920027340414         </td><td>2.09897734476157            </td><td>0.0358191243367423          </td><td>0.276632783066185           </td><td>1104348                     </td><td>rider/date/commute [Pre-HOV]</td></tr>\n",
       "</tbody>\n",
       "</table>\n"
      ],
      "text/latex": [
       "\\begin{tabular}{r|llllllll}\n",
       "  & model & Estimate & Std. Error & t value & Pr(>\\textbar{}t\\textbar{}) & r2 & N & granularity\\\\\n",
       "\\hline\n",
       "\timputed\\_new\\_buses & 2                                & 0.0203816624978698               & 0.0021176175266326               & 9.62480818256184                 & 6.2948821992348e-22              & 0.276632783066185                & 1104348                          & rider/date/commute {[}Pre-HOV{]}\\\\\n",
       "\timputed\\_new\\_buses:IsRouteSeattle\\_10\\_ride & 2                                & 0.00593842727766852              & 0.00282920027340414              & 2.09897734476157                 & 0.0358191243367423               & 0.276632783066185                & 1104348                          & rider/date/commute {[}Pre-HOV{]}\\\\\n",
       "\\end{tabular}\n"
      ],
      "text/markdown": [
       "\n",
       "| <!--/--> | model | Estimate | Std. Error | t value | Pr(>|t|) | r2 | N | granularity |\n",
       "|---|---|---|---|---|---|---|---|---|\n",
       "| imputed_new_buses | 2                            | 0.0203816624978698           | 0.0021176175266326           | 9.62480818256184             | 6.2948821992348e-22          | 0.276632783066185            | 1104348                      | rider/date/commute [Pre-HOV] |\n",
       "| imputed_new_buses:IsRouteSeattle_10_ride | 2                            | 0.00593842727766852          | 0.00282920027340414          | 2.09897734476157             | 0.0358191243367423           | 0.276632783066185            | 1104348                      | rider/date/commute [Pre-HOV] |\n",
       "\n"
      ],
      "text/plain": [
       "                                         model Estimate           \n",
       "imputed_new_buses                        2     0.0203816624978698 \n",
       "imputed_new_buses:IsRouteSeattle_10_ride 2     0.00593842727766852\n",
       "                                         Std. Error          t value         \n",
       "imputed_new_buses                        0.0021176175266326  9.62480818256184\n",
       "imputed_new_buses:IsRouteSeattle_10_ride 0.00282920027340414 2.09897734476157\n",
       "                                         Pr(>|t|)            r2               \n",
       "imputed_new_buses                        6.2948821992348e-22 0.276632783066185\n",
       "imputed_new_buses:IsRouteSeattle_10_ride 0.0358191243367423  0.276632783066185\n",
       "                                         N       granularity                 \n",
       "imputed_new_buses                        1104348 rider/date/commute [Pre-HOV]\n",
       "imputed_new_buses:IsRouteSeattle_10_ride 1104348 rider/date/commute [Pre-HOV]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "(table2_model2_pre_HOV = fit_ridership_logit_models(data = commute_ride_data[(!SR520WBHOV) & \n",
    "                                                            (!SR520EBHOV)],\n",
    "                            predictors=c(\"imputed_new_buses\",\n",
    "                                            \"imputed_new_buses:IsRouteSeattle_10_ride\"),\n",
    "                            adjust_for=c(\"f_favorite_route\",\n",
    "                                            \"f_commutes_since_last_ride\"),\n",
    "                            model=2,\n",
    "                            granularity=\"rider/date/commute [Pre-HOV]\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "===============================================\n",
      "Model  3 :\n",
      "===============================================\n",
      "\n",
      "\n",
      "Coefficients from Linear model (adjust_for effects omitted):\n",
      "                                             Estimate  Std. Error    t value\n",
      "imputed_new_buses                         0.028970849 0.002807211 10.3201556\n",
      "imputed_new_buses:IsRouteSeattle_10_ride -0.002925051 0.003998815 -0.7314796\n",
      "                                             Pr(>|t|)\n",
      "imputed_new_buses                        5.748150e-25\n",
      "imputed_new_buses:IsRouteSeattle_10_ride 4.644866e-01\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<table>\n",
       "<thead><tr><th></th><th scope=col>model</th><th scope=col>Estimate</th><th scope=col>Std. Error</th><th scope=col>t value</th><th scope=col>Pr(&gt;|t|)</th><th scope=col>r2</th><th scope=col>N</th><th scope=col>granularity</th></tr></thead>\n",
       "<tbody>\n",
       "\t<tr><th scope=row>imputed_new_buses</th><td>3                                                        </td><td>0.028970849148144                                        </td><td>0.00280721050623915                                      </td><td>10.3201555721436                                         </td><td>5.748150334968e-25                                       </td><td>0.304062522412056                                        </td><td>471656                                                   </td><td>rider/date/commute [Pre-HOV; First stop preferred riders]</td></tr>\n",
       "\t<tr><th scope=row>imputed_new_buses:IsRouteSeattle_10_ride</th><td>3                                                        </td><td>-0.00292505142036499                                     </td><td>0.00399881456320739                                      </td><td>-0.731479635809581                                       </td><td>0.464486602147099                                        </td><td>0.304062522412056                                        </td><td>471656                                                   </td><td>rider/date/commute [Pre-HOV; First stop preferred riders]</td></tr>\n",
       "</tbody>\n",
       "</table>\n"
      ],
      "text/latex": [
       "\\begin{tabular}{r|llllllll}\n",
       "  & model & Estimate & Std. Error & t value & Pr(>\\textbar{}t\\textbar{}) & r2 & N & granularity\\\\\n",
       "\\hline\n",
       "\timputed\\_new\\_buses & 3                                                             & 0.028970849148144                                             & 0.00280721050623915                                           & 10.3201555721436                                              & 5.748150334968e-25                                            & 0.304062522412056                                             & 471656                                                        & rider/date/commute {[}Pre-HOV; First stop preferred riders{]}\\\\\n",
       "\timputed\\_new\\_buses:IsRouteSeattle\\_10\\_ride & 3                                                             & -0.00292505142036499                                          & 0.00399881456320739                                           & -0.731479635809581                                            & 0.464486602147099                                             & 0.304062522412056                                             & 471656                                                        & rider/date/commute {[}Pre-HOV; First stop preferred riders{]}\\\\\n",
       "\\end{tabular}\n"
      ],
      "text/markdown": [
       "\n",
       "| <!--/--> | model | Estimate | Std. Error | t value | Pr(>|t|) | r2 | N | granularity |\n",
       "|---|---|---|---|---|---|---|---|---|\n",
       "| imputed_new_buses | 3                                                         | 0.028970849148144                                         | 0.00280721050623915                                       | 10.3201555721436                                          | 5.748150334968e-25                                        | 0.304062522412056                                         | 471656                                                    | rider/date/commute [Pre-HOV; First stop preferred riders] |\n",
       "| imputed_new_buses:IsRouteSeattle_10_ride | 3                                                         | -0.00292505142036499                                      | 0.00399881456320739                                       | -0.731479635809581                                        | 0.464486602147099                                         | 0.304062522412056                                         | 471656                                                    | rider/date/commute [Pre-HOV; First stop preferred riders] |\n",
       "\n"
      ],
      "text/plain": [
       "                                         model Estimate            \n",
       "imputed_new_buses                        3     0.028970849148144   \n",
       "imputed_new_buses:IsRouteSeattle_10_ride 3     -0.00292505142036499\n",
       "                                         Std. Error          t value           \n",
       "imputed_new_buses                        0.00280721050623915 10.3201555721436  \n",
       "imputed_new_buses:IsRouteSeattle_10_ride 0.00399881456320739 -0.731479635809581\n",
       "                                         Pr(>|t|)           r2               \n",
       "imputed_new_buses                        5.748150334968e-25 0.304062522412056\n",
       "imputed_new_buses:IsRouteSeattle_10_ride 0.464486602147099  0.304062522412056\n",
       "                                         N     \n",
       "imputed_new_buses                        471656\n",
       "imputed_new_buses:IsRouteSeattle_10_ride 471656\n",
       "                                         granularity                                              \n",
       "imputed_new_buses                        rider/date/commute [Pre-HOV; First stop preferred riders]\n",
       "imputed_new_buses:IsRouteSeattle_10_ride rider/date/commute [Pre-HOV; First stop preferred riders]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "(table2_model3_pre_HOV = fit_ridership_logit_models(data = commute_ride_data[(!SR520WBHOV) &  \n",
    "                                                            (!SR520EBHOV) & \n",
    "                                                            (first_stop_10_ride >= 0.5)],\n",
    "                            predictors=c(\"imputed_new_buses\",\n",
    "                                            \"imputed_new_buses:IsRouteSeattle_10_ride\"),\n",
    "                            adjust_for=c(\"f_favorite_route\",\n",
    "                                            \"f_commutes_since_last_ride\"),\n",
    "                            model=3,\n",
    "                            granularity=\"rider/date/commute [Pre-HOV; First stop preferred riders]\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "===============================================\n",
      "Model  4 :\n",
      "===============================================\n",
      "\n",
      "\n",
      "Coefficients from Linear model (adjust_for effects omitted):\n",
      "                                            Estimate  Std. Error  t value\n",
      "imputed_new_buses                        0.021145604 0.002379404 8.886932\n",
      "imputed_new_buses:IsRouteSeattle_10_ride 0.007634302 0.003345403 2.282028\n",
      "                                             Pr(>|t|)\n",
      "imputed_new_buses                        6.295277e-19\n",
      "imputed_new_buses:IsRouteSeattle_10_ride 2.248798e-02\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<table>\n",
       "<thead><tr><th></th><th scope=col>model</th><th scope=col>Estimate</th><th scope=col>Std. Error</th><th scope=col>t value</th><th scope=col>Pr(&gt;|t|)</th><th scope=col>r2</th><th scope=col>N</th><th scope=col>granularity</th></tr></thead>\n",
       "<tbody>\n",
       "\t<tr><th scope=row>imputed_new_buses</th><td>4                                                       </td><td>0.0211456043717674                                      </td><td>0.00237940431141981                                     </td><td>8.88693202339775                                        </td><td>6.29527683217756e-19                                    </td><td>0.287406420981424                                       </td><td>753890                                                  </td><td>rider/date/commute [Pre-HOV; Last stop preferred riders]</td></tr>\n",
       "\t<tr><th scope=row>imputed_new_buses:IsRouteSeattle_10_ride</th><td>4                                                       </td><td>0.00763430242479268                                     </td><td>0.00334540290394017                                     </td><td>2.28202779874469                                        </td><td>0.0224879764426814                                      </td><td>0.287406420981424                                       </td><td>753890                                                  </td><td>rider/date/commute [Pre-HOV; Last stop preferred riders]</td></tr>\n",
       "</tbody>\n",
       "</table>\n"
      ],
      "text/latex": [
       "\\begin{tabular}{r|llllllll}\n",
       "  & model & Estimate & Std. Error & t value & Pr(>\\textbar{}t\\textbar{}) & r2 & N & granularity\\\\\n",
       "\\hline\n",
       "\timputed\\_new\\_buses & 4                                                            & 0.0211456043717674                                           & 0.00237940431141981                                          & 8.88693202339775                                             & 6.29527683217756e-19                                         & 0.287406420981424                                            & 753890                                                       & rider/date/commute {[}Pre-HOV; Last stop preferred riders{]}\\\\\n",
       "\timputed\\_new\\_buses:IsRouteSeattle\\_10\\_ride & 4                                                            & 0.00763430242479268                                          & 0.00334540290394017                                          & 2.28202779874469                                             & 0.0224879764426814                                           & 0.287406420981424                                            & 753890                                                       & rider/date/commute {[}Pre-HOV; Last stop preferred riders{]}\\\\\n",
       "\\end{tabular}\n"
      ],
      "text/markdown": [
       "\n",
       "| <!--/--> | model | Estimate | Std. Error | t value | Pr(>|t|) | r2 | N | granularity |\n",
       "|---|---|---|---|---|---|---|---|---|\n",
       "| imputed_new_buses | 4                                                        | 0.0211456043717674                                       | 0.00237940431141981                                      | 8.88693202339775                                         | 6.29527683217756e-19                                     | 0.287406420981424                                        | 753890                                                   | rider/date/commute [Pre-HOV; Last stop preferred riders] |\n",
       "| imputed_new_buses:IsRouteSeattle_10_ride | 4                                                        | 0.00763430242479268                                      | 0.00334540290394017                                      | 2.28202779874469                                         | 0.0224879764426814                                       | 0.287406420981424                                        | 753890                                                   | rider/date/commute [Pre-HOV; Last stop preferred riders] |\n",
       "\n"
      ],
      "text/plain": [
       "                                         model Estimate           \n",
       "imputed_new_buses                        4     0.0211456043717674 \n",
       "imputed_new_buses:IsRouteSeattle_10_ride 4     0.00763430242479268\n",
       "                                         Std. Error          t value         \n",
       "imputed_new_buses                        0.00237940431141981 8.88693202339775\n",
       "imputed_new_buses:IsRouteSeattle_10_ride 0.00334540290394017 2.28202779874469\n",
       "                                         Pr(>|t|)             r2               \n",
       "imputed_new_buses                        6.29527683217756e-19 0.287406420981424\n",
       "imputed_new_buses:IsRouteSeattle_10_ride 0.0224879764426814   0.287406420981424\n",
       "                                         N     \n",
       "imputed_new_buses                        753890\n",
       "imputed_new_buses:IsRouteSeattle_10_ride 753890\n",
       "                                         granularity                                             \n",
       "imputed_new_buses                        rider/date/commute [Pre-HOV; Last stop preferred riders]\n",
       "imputed_new_buses:IsRouteSeattle_10_ride rider/date/commute [Pre-HOV; Last stop preferred riders]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "(table2_model4_pre_HOV = fit_ridership_logit_models(data = commute_ride_data[(!SR520WBHOV) & \n",
    "                                                            (!SR520EBHOV) & \n",
    "                                                            (last_stop_10_ride >= 0.5)],\n",
    "                            predictors=c(\"imputed_new_buses\",\n",
    "                                            \"imputed_new_buses:IsRouteSeattle_10_ride\"),\n",
    "                            adjust_for=c(\"f_favorite_route\",\n",
    "                                            \"f_commutes_since_last_ride\"),\n",
    "                            model=4,\n",
    "                            granularity=\"rider/date/commute [Pre-HOV; Last stop preferred riders]\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "===============================================\n",
      "Model  5 :\n",
      "===============================================\n",
      "\n",
      "\n",
      "Coefficients from Linear model (adjust_for effects omitted):\n",
      "    Estimate   Std. Error      t value     Pr(>|t|) \n",
      "2.574771e-02 1.931180e-03 1.333263e+01 1.511593e-40 \n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<table>\n",
       "<thead><tr><th scope=col>model</th><th scope=col>Estimate</th><th scope=col>Std. Error</th><th scope=col>t value</th><th scope=col>Pr(&gt;|t|)</th><th scope=col>r2</th><th scope=col>N</th><th scope=col>granularity</th></tr></thead>\n",
       "<tbody>\n",
       "\t<tr><td>5                                                     </td><td>0.0257477137091702                                    </td><td>0.00193117977737595                                   </td><td>13.3326342843936                                      </td><td>1.51159273840049e-40                                  </td><td>0.255026901467857                                     </td><td>733928                                                </td><td>rider/date/commute [Pre-HOV; Seattle preferred riders]</td></tr>\n",
       "</tbody>\n",
       "</table>\n"
      ],
      "text/latex": [
       "\\begin{tabular}{llllllll}\n",
       " model & Estimate & Std. Error & t value & Pr(>\\textbar{}t\\textbar{}) & r2 & N & granularity\\\\\n",
       "\\hline\n",
       "\t 5                                                          & 0.0257477137091702                                         & 0.00193117977737595                                        & 13.3326342843936                                           & 1.51159273840049e-40                                       & 0.255026901467857                                          & 733928                                                     & rider/date/commute {[}Pre-HOV; Seattle preferred riders{]}\\\\\n",
       "\\end{tabular}\n"
      ],
      "text/markdown": [
       "\n",
       "| model | Estimate | Std. Error | t value | Pr(>|t|) | r2 | N | granularity |\n",
       "|---|---|---|---|---|---|---|---|\n",
       "| 5                                                      | 0.0257477137091702                                     | 0.00193117977737595                                    | 13.3326342843936                                       | 1.51159273840049e-40                                   | 0.255026901467857                                      | 733928                                                 | rider/date/commute [Pre-HOV; Seattle preferred riders] |\n",
       "\n"
      ],
      "text/plain": [
       "     model Estimate           Std. Error          t value         \n",
       "[1,] 5     0.0257477137091702 0.00193117977737595 13.3326342843936\n",
       "     Pr(>|t|)             r2                N     \n",
       "[1,] 1.51159273840049e-40 0.255026901467857 733928\n",
       "     granularity                                           \n",
       "[1,] rider/date/commute [Pre-HOV; Seattle preferred riders]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "(table2_model5_pre_HOV = fit_ridership_logit_models(data = commute_ride_data[(!SR520WBHOV) & \n",
    "                                                            (!SR520EBHOV) & \n",
    "                                                            IsRouteSeattle_10_ride >= 0.5],\n",
    "                            predictors=c(\"imputed_new_buses\"),\n",
    "                            adjust_for=c(\"f_favorite_route\",\n",
    "                                            \"f_commutes_since_last_ride\"),\n",
    "                            model=5,\n",
    "                            granularity=\"rider/date/commute [Pre-HOV; Seattle preferred riders]\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "===============================================\n",
      "Model  6 :\n",
      "===============================================\n",
      "\n",
      "\n",
      "Coefficients from Linear model (adjust_for effects omitted):\n",
      "    Estimate   Std. Error      t value     Pr(>|t|) \n",
      "2.116723e-02 2.075529e-03 1.019847e+01 2.029192e-24 \n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<table>\n",
       "<thead><tr><th scope=col>model</th><th scope=col>Estimate</th><th scope=col>Std. Error</th><th scope=col>t value</th><th scope=col>Pr(&gt;|t|)</th><th scope=col>r2</th><th scope=col>N</th><th scope=col>granularity</th></tr></thead>\n",
       "<tbody>\n",
       "\t<tr><td>6                                                         </td><td>0.0211672276253699                                        </td><td>0.00207552929076805                                       </td><td>10.1984721292644                                          </td><td>2.02919245490518e-24                                      </td><td>0.321385221399999                                         </td><td>370670                                                    </td><td>rider/date/commute [Pre-HOV; Non-Seattle preferred riders]</td></tr>\n",
       "</tbody>\n",
       "</table>\n"
      ],
      "text/latex": [
       "\\begin{tabular}{llllllll}\n",
       " model & Estimate & Std. Error & t value & Pr(>\\textbar{}t\\textbar{}) & r2 & N & granularity\\\\\n",
       "\\hline\n",
       "\t 6                                                              & 0.0211672276253699                                             & 0.00207552929076805                                            & 10.1984721292644                                               & 2.02919245490518e-24                                           & 0.321385221399999                                              & 370670                                                         & rider/date/commute {[}Pre-HOV; Non-Seattle preferred riders{]}\\\\\n",
       "\\end{tabular}\n"
      ],
      "text/markdown": [
       "\n",
       "| model | Estimate | Std. Error | t value | Pr(>|t|) | r2 | N | granularity |\n",
       "|---|---|---|---|---|---|---|---|\n",
       "| 6                                                          | 0.0211672276253699                                         | 0.00207552929076805                                        | 10.1984721292644                                           | 2.02919245490518e-24                                       | 0.321385221399999                                          | 370670                                                     | rider/date/commute [Pre-HOV; Non-Seattle preferred riders] |\n",
       "\n"
      ],
      "text/plain": [
       "     model Estimate           Std. Error          t value         \n",
       "[1,] 6     0.0211672276253699 0.00207552929076805 10.1984721292644\n",
       "     Pr(>|t|)             r2                N     \n",
       "[1,] 2.02919245490518e-24 0.321385221399999 370670\n",
       "     granularity                                               \n",
       "[1,] rider/date/commute [Pre-HOV; Non-Seattle preferred riders]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "(table2_model6_pre_HOV = fit_ridership_logit_models(data = commute_ride_data[(!SR520WBHOV) & \n",
    "                                                            (!SR520EBHOV) & \n",
    "                                                            IsRouteSeattle_10_ride <= 0.5],\n",
    "                            predictors=c(\"imputed_new_buses\"),\n",
    "                            adjust_for=c(\"f_favorite_route\",\n",
    "                                            \"f_commutes_since_last_ride\"),\n",
    "                            model=6,\n",
    "                            granularity=\"rider/date/commute [Pre-HOV; Non-Seattle preferred riders]\"))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Table 2 Summary Statistics \n",
    "* Pre 520 HOV data only"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table>\n",
       "<thead><tr><th></th><th scope=col>model</th><th scope=col>Estimate</th><th scope=col>Std. Error</th><th scope=col>t value</th><th scope=col>Pr(&gt;|t|)</th><th scope=col>r2</th><th scope=col>N</th><th scope=col>granularity</th></tr></thead>\n",
       "<tbody>\n",
       "\t<tr><th scope=row></th><td>1                                                         </td><td>0.0236757651855375                                        </td><td>0.00142173916370504                                       </td><td>16.6526784869867                                          </td><td>2.94474161476437e-62                                      </td><td>0.276629897089897                                         </td><td>1104348                                                   </td><td>rider/date/commute [Pre-HOV]                              </td></tr>\n",
       "\t<tr><th scope=row>imputed_new_buses</th><td>2                                                         </td><td>0.0203816624978698                                        </td><td>0.0021176175266326                                        </td><td>9.62480818256184                                          </td><td>6.2948821992348e-22                                       </td><td>0.276632783066185                                         </td><td>1104348                                                   </td><td>rider/date/commute [Pre-HOV]                              </td></tr>\n",
       "\t<tr><th scope=row>imputed_new_buses:IsRouteSeattle_10_ride</th><td>2                                                         </td><td>0.00593842727766852                                       </td><td>0.00282920027340414                                       </td><td>2.09897734476157                                          </td><td>0.0358191243367423                                        </td><td>0.276632783066185                                         </td><td>1104348                                                   </td><td>rider/date/commute [Pre-HOV]                              </td></tr>\n",
       "\t<tr><th scope=row>imputed_new_buses</th><td>3                                                         </td><td>0.028970849148144                                         </td><td>0.00280721050623915                                       </td><td>10.3201555721436                                          </td><td>5.748150334968e-25                                        </td><td>0.304062522412056                                         </td><td>471656                                                    </td><td>rider/date/commute [Pre-HOV; First stop preferred riders] </td></tr>\n",
       "\t<tr><th scope=row>imputed_new_buses:IsRouteSeattle_10_ride</th><td>3                                                         </td><td>-0.00292505142036499                                      </td><td>0.00399881456320739                                       </td><td>-0.731479635809581                                        </td><td>0.464486602147099                                         </td><td>0.304062522412056                                         </td><td>471656                                                    </td><td>rider/date/commute [Pre-HOV; First stop preferred riders] </td></tr>\n",
       "\t<tr><th scope=row>imputed_new_buses</th><td>4                                                         </td><td>0.0211456043717674                                        </td><td>0.00237940431141981                                       </td><td>8.88693202339775                                          </td><td>6.29527683217756e-19                                      </td><td>0.287406420981424                                         </td><td>753890                                                    </td><td>rider/date/commute [Pre-HOV; Last stop preferred riders]  </td></tr>\n",
       "\t<tr><th scope=row>imputed_new_buses:IsRouteSeattle_10_ride</th><td>4                                                         </td><td>0.00763430242479268                                       </td><td>0.00334540290394017                                       </td><td>2.28202779874469                                          </td><td>0.0224879764426814                                        </td><td>0.287406420981424                                         </td><td>753890                                                    </td><td>rider/date/commute [Pre-HOV; Last stop preferred riders]  </td></tr>\n",
       "\t<tr><th scope=row></th><td>5                                                         </td><td>0.0257477137091702                                        </td><td>0.00193117977737595                                       </td><td>13.3326342843936                                          </td><td>1.51159273840049e-40                                      </td><td>0.255026901467857                                         </td><td>733928                                                    </td><td>rider/date/commute [Pre-HOV; Seattle preferred riders]    </td></tr>\n",
       "\t<tr><th scope=row></th><td>6                                                         </td><td>0.0211672276253699                                        </td><td>0.00207552929076805                                       </td><td>10.1984721292644                                          </td><td>2.02919245490518e-24                                      </td><td>0.321385221399999                                         </td><td>370670                                                    </td><td>rider/date/commute [Pre-HOV; Non-Seattle preferred riders]</td></tr>\n",
       "</tbody>\n",
       "</table>\n"
      ],
      "text/latex": [
       "\\begin{tabular}{r|llllllll}\n",
       "  & model & Estimate & Std. Error & t value & Pr(>\\textbar{}t\\textbar{}) & r2 & N & granularity\\\\\n",
       "\\hline\n",
       "\t & 1                                                              & 0.0236757651855375                                             & 0.00142173916370504                                            & 16.6526784869867                                               & 2.94474161476437e-62                                           & 0.276629897089897                                              & 1104348                                                        & rider/date/commute {[}Pre-HOV{]}                              \\\\\n",
       "\timputed\\_new\\_buses & 2                                                              & 0.0203816624978698                                             & 0.0021176175266326                                             & 9.62480818256184                                               & 6.2948821992348e-22                                            & 0.276632783066185                                              & 1104348                                                        & rider/date/commute {[}Pre-HOV{]}                              \\\\\n",
       "\timputed\\_new\\_buses:IsRouteSeattle\\_10\\_ride & 2                                                              & 0.00593842727766852                                            & 0.00282920027340414                                            & 2.09897734476157                                               & 0.0358191243367423                                             & 0.276632783066185                                              & 1104348                                                        & rider/date/commute {[}Pre-HOV{]}                              \\\\\n",
       "\timputed\\_new\\_buses & 3                                                              & 0.028970849148144                                              & 0.00280721050623915                                            & 10.3201555721436                                               & 5.748150334968e-25                                             & 0.304062522412056                                              & 471656                                                         & rider/date/commute {[}Pre-HOV; First stop preferred riders{]} \\\\\n",
       "\timputed\\_new\\_buses:IsRouteSeattle\\_10\\_ride & 3                                                              & -0.00292505142036499                                           & 0.00399881456320739                                            & -0.731479635809581                                             & 0.464486602147099                                              & 0.304062522412056                                              & 471656                                                         & rider/date/commute {[}Pre-HOV; First stop preferred riders{]} \\\\\n",
       "\timputed\\_new\\_buses & 4                                                              & 0.0211456043717674                                             & 0.00237940431141981                                            & 8.88693202339775                                               & 6.29527683217756e-19                                           & 0.287406420981424                                              & 753890                                                         & rider/date/commute {[}Pre-HOV; Last stop preferred riders{]}  \\\\\n",
       "\timputed\\_new\\_buses:IsRouteSeattle\\_10\\_ride & 4                                                              & 0.00763430242479268                                            & 0.00334540290394017                                            & 2.28202779874469                                               & 0.0224879764426814                                             & 0.287406420981424                                              & 753890                                                         & rider/date/commute {[}Pre-HOV; Last stop preferred riders{]}  \\\\\n",
       "\t & 5                                                              & 0.0257477137091702                                             & 0.00193117977737595                                            & 13.3326342843936                                               & 1.51159273840049e-40                                           & 0.255026901467857                                              & 733928                                                         & rider/date/commute {[}Pre-HOV; Seattle preferred riders{]}    \\\\\n",
       "\t & 6                                                              & 0.0211672276253699                                             & 0.00207552929076805                                            & 10.1984721292644                                               & 2.02919245490518e-24                                           & 0.321385221399999                                              & 370670                                                         & rider/date/commute {[}Pre-HOV; Non-Seattle preferred riders{]}\\\\\n",
       "\\end{tabular}\n"
      ],
      "text/markdown": [
       "\n",
       "| <!--/--> | model | Estimate | Std. Error | t value | Pr(>|t|) | r2 | N | granularity |\n",
       "|---|---|---|---|---|---|---|---|---|\n",
       "|  | 1                                                          | 0.0236757651855375                                         | 0.00142173916370504                                        | 16.6526784869867                                           | 2.94474161476437e-62                                       | 0.276629897089897                                          | 1104348                                                    | rider/date/commute [Pre-HOV]                               |\n",
       "| imputed_new_buses | 2                                                          | 0.0203816624978698                                         | 0.0021176175266326                                         | 9.62480818256184                                           | 6.2948821992348e-22                                        | 0.276632783066185                                          | 1104348                                                    | rider/date/commute [Pre-HOV]                               |\n",
       "| imputed_new_buses:IsRouteSeattle_10_ride | 2                                                          | 0.00593842727766852                                        | 0.00282920027340414                                        | 2.09897734476157                                           | 0.0358191243367423                                         | 0.276632783066185                                          | 1104348                                                    | rider/date/commute [Pre-HOV]                               |\n",
       "| imputed_new_buses | 3                                                          | 0.028970849148144                                          | 0.00280721050623915                                        | 10.3201555721436                                           | 5.748150334968e-25                                         | 0.304062522412056                                          | 471656                                                     | rider/date/commute [Pre-HOV; First stop preferred riders]  |\n",
       "| imputed_new_buses:IsRouteSeattle_10_ride | 3                                                          | -0.00292505142036499                                       | 0.00399881456320739                                        | -0.731479635809581                                         | 0.464486602147099                                          | 0.304062522412056                                          | 471656                                                     | rider/date/commute [Pre-HOV; First stop preferred riders]  |\n",
       "| imputed_new_buses | 4                                                          | 0.0211456043717674                                         | 0.00237940431141981                                        | 8.88693202339775                                           | 6.29527683217756e-19                                       | 0.287406420981424                                          | 753890                                                     | rider/date/commute [Pre-HOV; Last stop preferred riders]   |\n",
       "| imputed_new_buses:IsRouteSeattle_10_ride | 4                                                          | 0.00763430242479268                                        | 0.00334540290394017                                        | 2.28202779874469                                           | 0.0224879764426814                                         | 0.287406420981424                                          | 753890                                                     | rider/date/commute [Pre-HOV; Last stop preferred riders]   |\n",
       "|  | 5                                                          | 0.0257477137091702                                         | 0.00193117977737595                                        | 13.3326342843936                                           | 1.51159273840049e-40                                       | 0.255026901467857                                          | 733928                                                     | rider/date/commute [Pre-HOV; Seattle preferred riders]     |\n",
       "|  | 6                                                          | 0.0211672276253699                                         | 0.00207552929076805                                        | 10.1984721292644                                           | 2.02919245490518e-24                                       | 0.321385221399999                                          | 370670                                                     | rider/date/commute [Pre-HOV; Non-Seattle preferred riders] |\n",
       "\n"
      ],
      "text/plain": [
       "                                         model Estimate            \n",
       "                                         1     0.0236757651855375  \n",
       "imputed_new_buses                        2     0.0203816624978698  \n",
       "imputed_new_buses:IsRouteSeattle_10_ride 2     0.00593842727766852 \n",
       "imputed_new_buses                        3     0.028970849148144   \n",
       "imputed_new_buses:IsRouteSeattle_10_ride 3     -0.00292505142036499\n",
       "imputed_new_buses                        4     0.0211456043717674  \n",
       "imputed_new_buses:IsRouteSeattle_10_ride 4     0.00763430242479268 \n",
       "                                         5     0.0257477137091702  \n",
       "                                         6     0.0211672276253699  \n",
       "                                         Std. Error          t value           \n",
       "                                         0.00142173916370504 16.6526784869867  \n",
       "imputed_new_buses                        0.0021176175266326  9.62480818256184  \n",
       "imputed_new_buses:IsRouteSeattle_10_ride 0.00282920027340414 2.09897734476157  \n",
       "imputed_new_buses                        0.00280721050623915 10.3201555721436  \n",
       "imputed_new_buses:IsRouteSeattle_10_ride 0.00399881456320739 -0.731479635809581\n",
       "imputed_new_buses                        0.00237940431141981 8.88693202339775  \n",
       "imputed_new_buses:IsRouteSeattle_10_ride 0.00334540290394017 2.28202779874469  \n",
       "                                         0.00193117977737595 13.3326342843936  \n",
       "                                         0.00207552929076805 10.1984721292644  \n",
       "                                         Pr(>|t|)             r2               \n",
       "                                         2.94474161476437e-62 0.276629897089897\n",
       "imputed_new_buses                        6.2948821992348e-22  0.276632783066185\n",
       "imputed_new_buses:IsRouteSeattle_10_ride 0.0358191243367423   0.276632783066185\n",
       "imputed_new_buses                        5.748150334968e-25   0.304062522412056\n",
       "imputed_new_buses:IsRouteSeattle_10_ride 0.464486602147099    0.304062522412056\n",
       "imputed_new_buses                        6.29527683217756e-19 0.287406420981424\n",
       "imputed_new_buses:IsRouteSeattle_10_ride 0.0224879764426814   0.287406420981424\n",
       "                                         1.51159273840049e-40 0.255026901467857\n",
       "                                         2.02919245490518e-24 0.321385221399999\n",
       "                                         N      \n",
       "                                         1104348\n",
       "imputed_new_buses                        1104348\n",
       "imputed_new_buses:IsRouteSeattle_10_ride 1104348\n",
       "imputed_new_buses                        471656 \n",
       "imputed_new_buses:IsRouteSeattle_10_ride 471656 \n",
       "imputed_new_buses                        753890 \n",
       "imputed_new_buses:IsRouteSeattle_10_ride 753890 \n",
       "                                         733928 \n",
       "                                         370670 \n",
       "                                         granularity                                               \n",
       "                                         rider/date/commute [Pre-HOV]                              \n",
       "imputed_new_buses                        rider/date/commute [Pre-HOV]                              \n",
       "imputed_new_buses:IsRouteSeattle_10_ride rider/date/commute [Pre-HOV]                              \n",
       "imputed_new_buses                        rider/date/commute [Pre-HOV; First stop preferred riders] \n",
       "imputed_new_buses:IsRouteSeattle_10_ride rider/date/commute [Pre-HOV; First stop preferred riders] \n",
       "imputed_new_buses                        rider/date/commute [Pre-HOV; Last stop preferred riders]  \n",
       "imputed_new_buses:IsRouteSeattle_10_ride rider/date/commute [Pre-HOV; Last stop preferred riders]  \n",
       "                                         rider/date/commute [Pre-HOV; Seattle preferred riders]    \n",
       "                                         rider/date/commute [Pre-HOV; Non-Seattle preferred riders]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "\n",
    "rbind( table2_model1_pre_HOV,\n",
    "       table2_model2_pre_HOV,\n",
    "       table2_model3_pre_HOV,\n",
    "       table2_model4_pre_HOV,\n",
    "       table2_model5_pre_HOV,\n",
    "       table2_model6_pre_HOV)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Fit the Models for Table 3 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "2"
      ],
      "text/latex": [
       "2"
      ],
      "text/markdown": [
       "2"
      ],
      "text/plain": [
       "[1] 2"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<table>\n",
       "<thead><tr><th></th><th scope=col>used</th><th scope=col>(Mb)</th><th scope=col>gc trigger</th><th scope=col>(Mb)</th><th scope=col>max used</th><th scope=col>(Mb)</th></tr></thead>\n",
       "<tbody>\n",
       "\t<tr><th scope=row>Ncells</th><td>  665109 </td><td> 35.6    </td><td>  2365308</td><td> 126.4   </td><td> 11278674</td><td> 602.4   </td></tr>\n",
       "\t<tr><th scope=row>Vcells</th><td>73963644 </td><td>564.3    </td><td>465506097</td><td>3551.6   </td><td>685251204</td><td>5228.1   </td></tr>\n",
       "</tbody>\n",
       "</table>\n"
      ],
      "text/latex": [
       "\\begin{tabular}{r|llllll}\n",
       "  & used & (Mb) & gc trigger & (Mb) & max used & (Mb)\\\\\n",
       "\\hline\n",
       "\tNcells &   665109  &  35.6     &   2365308 &  126.4    &  11278674 &  602.4   \\\\\n",
       "\tVcells & 73963644  & 564.3     & 465506097 & 3551.6    & 685251204 & 5228.1   \\\\\n",
       "\\end{tabular}\n"
      ],
      "text/markdown": [
       "\n",
       "| <!--/--> | used | (Mb) | gc trigger | (Mb) | max used | (Mb) |\n",
       "|---|---|---|---|---|---|---|\n",
       "| Ncells |   665109  |  35.6     |   2365308 |  126.4    |  11278674 |  602.4    |\n",
       "| Vcells | 73963644  | 564.3     | 465506097 | 3551.6    | 685251204 | 5228.1    |\n",
       "\n"
      ],
      "text/plain": [
       "       used     (Mb)  gc trigger (Mb)   max used  (Mb)  \n",
       "Ncells   665109  35.6   2365308   126.4  11278674  602.4\n",
       "Vcells 73963644 564.3 465506097  3551.6 685251204 5228.1"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "1 + 1\n",
    "gc()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "===============================================\n",
      "Model  1 :\n",
      "===============================================\n",
      "\n",
      "\n",
      "Coefficients from Linear model (adjust_for effects omitted):\n",
      "    Estimate   Std. Error      t value     Pr(>|t|) \n",
      "1.838344e-02 1.312352e-03 1.400801e+01 1.400102e-44 \n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<table>\n",
       "<thead><tr><th scope=col>model</th><th scope=col>Estimate</th><th scope=col>Std. Error</th><th scope=col>t value</th><th scope=col>Pr(&gt;|t|)</th><th scope=col>r2</th><th scope=col>N</th><th scope=col>granularity</th></tr></thead>\n",
       "<tbody>\n",
       "\t<tr><td>1                   </td><td>0.0183834420658064  </td><td>0.00131235215593952 </td><td>14.0080099557162    </td><td>1.40010244000293e-44</td><td>0.3044796455947     </td><td>1792156             </td><td>rider/date/commute  </td></tr>\n",
       "</tbody>\n",
       "</table>\n"
      ],
      "text/latex": [
       "\\begin{tabular}{llllllll}\n",
       " model & Estimate & Std. Error & t value & Pr(>\\textbar{}t\\textbar{}) & r2 & N & granularity\\\\\n",
       "\\hline\n",
       "\t 1                    & 0.0183834420658064   & 0.00131235215593952  & 14.0080099557162     & 1.40010244000293e-44 & 0.3044796455947      & 1792156              & rider/date/commute  \\\\\n",
       "\\end{tabular}\n"
      ],
      "text/markdown": [
       "\n",
       "| model | Estimate | Std. Error | t value | Pr(>|t|) | r2 | N | granularity |\n",
       "|---|---|---|---|---|---|---|---|\n",
       "| 1                    | 0.0183834420658064   | 0.00131235215593952  | 14.0080099557162     | 1.40010244000293e-44 | 0.3044796455947      | 1792156              | rider/date/commute   |\n",
       "\n"
      ],
      "text/plain": [
       "     model Estimate           Std. Error          t value         \n",
       "[1,] 1     0.0183834420658064 0.00131235215593952 14.0080099557162\n",
       "     Pr(>|t|)             r2              N       granularity       \n",
       "[1,] 1.40010244000293e-44 0.3044796455947 1792156 rider/date/commute"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "\n",
    "(table3_model1 = fit_ridership_logit_models(data = commute_ride_data,\n",
    "                        predictors=c(\"post_hov:IsRouteSeattle_10_ride\"),\n",
    "                        adjust_for=c(\"imputed_new_buses + AfternoonId + fDate\",\n",
    "                                        \"f_commutes_since_last_ride\",\n",
    "                                        \"f_favorite_route\"),\n",
    "                        model=1,\n",
    "                        granularity=\"rider/date/commute\"))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "===============================================\n",
      "Model  2 :\n",
      "===============================================\n",
      "\n",
      "\n",
      "Coefficients from Linear model (adjust_for effects omitted):\n",
      "                                                    Estimate  Std. Error\n",
      "post_hov:IsRouteSeattle_10_ride                  0.009638937 0.002816472\n",
      "is_peak_10_ride                                  0.009724509 0.002073547\n",
      "IsRouteSeattle_10_ride:is_peak_10_ride           0.027822920 0.002505539\n",
      "post_hov:is_peak_10_ride                        -0.024136687 0.003280753\n",
      "post_hov:IsRouteSeattle_10_ride:is_peak_10_ride  0.012018584 0.003997005\n",
      "                                                  t value     Pr(>|t|)\n",
      "post_hov:IsRouteSeattle_10_ride                  3.422344 6.208510e-04\n",
      "is_peak_10_ride                                  4.689794 2.735002e-06\n",
      "IsRouteSeattle_10_ride:is_peak_10_ride          11.104564 1.194544e-28\n",
      "post_hov:is_peak_10_ride                        -7.357056 1.880901e-13\n",
      "post_hov:IsRouteSeattle_10_ride:is_peak_10_ride  3.006897 2.639326e-03\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<table>\n",
       "<thead><tr><th></th><th scope=col>model</th><th scope=col>Estimate</th><th scope=col>Std. Error</th><th scope=col>t value</th><th scope=col>Pr(&gt;|t|)</th><th scope=col>r2</th><th scope=col>N</th><th scope=col>granularity</th></tr></thead>\n",
       "<tbody>\n",
       "\t<tr><th scope=row>post_hov:IsRouteSeattle_10_ride</th><td>2                   </td><td>0.00963893724650586 </td><td>0.00281647234222826 </td><td>3.42234400884618    </td><td>0.000620850962943762</td><td>0.304835246011862   </td><td>1792156             </td><td>rider/date/commute  </td></tr>\n",
       "\t<tr><th scope=row>is_peak_10_ride</th><td>2                   </td><td>0.00972450904195021 </td><td>0.00207354709992748 </td><td>4.68979414178261    </td><td>2.73500153213254e-06</td><td>0.304835246011862   </td><td>1792156             </td><td>rider/date/commute  </td></tr>\n",
       "\t<tr><th scope=row>IsRouteSeattle_10_ride:is_peak_10_ride</th><td>2                   </td><td>0.0278229201357811  </td><td>0.00250553908896106 </td><td>11.1045643863086    </td><td>1.19454364868092e-28</td><td>0.304835246011862   </td><td>1792156             </td><td>rider/date/commute  </td></tr>\n",
       "\t<tr><th scope=row>post_hov:is_peak_10_ride</th><td>2                   </td><td>-0.0241366870506926 </td><td>0.00328075346524461 </td><td>-7.3570560258154    </td><td>1.88090135317251e-13</td><td>0.304835246011862   </td><td>1792156             </td><td>rider/date/commute  </td></tr>\n",
       "\t<tr><th scope=row>post_hov:IsRouteSeattle_10_ride:is_peak_10_ride</th><td>2                   </td><td>0.0120185839852569  </td><td>0.00399700518418931 </td><td>3.00689727218718    </td><td>0.00263932594521174 </td><td>0.304835246011862   </td><td>1792156             </td><td>rider/date/commute  </td></tr>\n",
       "</tbody>\n",
       "</table>\n"
      ],
      "text/latex": [
       "\\begin{tabular}{r|llllllll}\n",
       "  & model & Estimate & Std. Error & t value & Pr(>\\textbar{}t\\textbar{}) & r2 & N & granularity\\\\\n",
       "\\hline\n",
       "\tpost\\_hov:IsRouteSeattle\\_10\\_ride & 2                    & 0.00963893724650586  & 0.00281647234222826  & 3.42234400884618     & 0.000620850962943762 & 0.304835246011862    & 1792156              & rider/date/commute  \\\\\n",
       "\tis\\_peak\\_10\\_ride & 2                    & 0.00972450904195021  & 0.00207354709992748  & 4.68979414178261     & 2.73500153213254e-06 & 0.304835246011862    & 1792156              & rider/date/commute  \\\\\n",
       "\tIsRouteSeattle\\_10\\_ride:is\\_peak\\_10\\_ride & 2                    & 0.0278229201357811   & 0.00250553908896106  & 11.1045643863086     & 1.19454364868092e-28 & 0.304835246011862    & 1792156              & rider/date/commute  \\\\\n",
       "\tpost\\_hov:is\\_peak\\_10\\_ride & 2                    & -0.0241366870506926  & 0.00328075346524461  & -7.3570560258154     & 1.88090135317251e-13 & 0.304835246011862    & 1792156              & rider/date/commute  \\\\\n",
       "\tpost\\_hov:IsRouteSeattle\\_10\\_ride:is\\_peak\\_10\\_ride & 2                    & 0.0120185839852569   & 0.00399700518418931  & 3.00689727218718     & 0.00263932594521174  & 0.304835246011862    & 1792156              & rider/date/commute  \\\\\n",
       "\\end{tabular}\n"
      ],
      "text/markdown": [
       "\n",
       "| <!--/--> | model | Estimate | Std. Error | t value | Pr(>|t|) | r2 | N | granularity |\n",
       "|---|---|---|---|---|---|---|---|---|\n",
       "| post_hov:IsRouteSeattle_10_ride | 2                    | 0.00963893724650586  | 0.00281647234222826  | 3.42234400884618     | 0.000620850962943762 | 0.304835246011862    | 1792156              | rider/date/commute   |\n",
       "| is_peak_10_ride | 2                    | 0.00972450904195021  | 0.00207354709992748  | 4.68979414178261     | 2.73500153213254e-06 | 0.304835246011862    | 1792156              | rider/date/commute   |\n",
       "| IsRouteSeattle_10_ride:is_peak_10_ride | 2                    | 0.0278229201357811   | 0.00250553908896106  | 11.1045643863086     | 1.19454364868092e-28 | 0.304835246011862    | 1792156              | rider/date/commute   |\n",
       "| post_hov:is_peak_10_ride | 2                    | -0.0241366870506926  | 0.00328075346524461  | -7.3570560258154     | 1.88090135317251e-13 | 0.304835246011862    | 1792156              | rider/date/commute   |\n",
       "| post_hov:IsRouteSeattle_10_ride:is_peak_10_ride | 2                    | 0.0120185839852569   | 0.00399700518418931  | 3.00689727218718     | 0.00263932594521174  | 0.304835246011862    | 1792156              | rider/date/commute   |\n",
       "\n"
      ],
      "text/plain": [
       "                                                model Estimate           \n",
       "post_hov:IsRouteSeattle_10_ride                 2     0.00963893724650586\n",
       "is_peak_10_ride                                 2     0.00972450904195021\n",
       "IsRouteSeattle_10_ride:is_peak_10_ride          2     0.0278229201357811 \n",
       "post_hov:is_peak_10_ride                        2     -0.0241366870506926\n",
       "post_hov:IsRouteSeattle_10_ride:is_peak_10_ride 2     0.0120185839852569 \n",
       "                                                Std. Error         \n",
       "post_hov:IsRouteSeattle_10_ride                 0.00281647234222826\n",
       "is_peak_10_ride                                 0.00207354709992748\n",
       "IsRouteSeattle_10_ride:is_peak_10_ride          0.00250553908896106\n",
       "post_hov:is_peak_10_ride                        0.00328075346524461\n",
       "post_hov:IsRouteSeattle_10_ride:is_peak_10_ride 0.00399700518418931\n",
       "                                                t value         \n",
       "post_hov:IsRouteSeattle_10_ride                 3.42234400884618\n",
       "is_peak_10_ride                                 4.68979414178261\n",
       "IsRouteSeattle_10_ride:is_peak_10_ride          11.1045643863086\n",
       "post_hov:is_peak_10_ride                        -7.3570560258154\n",
       "post_hov:IsRouteSeattle_10_ride:is_peak_10_ride 3.00689727218718\n",
       "                                                Pr(>|t|)            \n",
       "post_hov:IsRouteSeattle_10_ride                 0.000620850962943762\n",
       "is_peak_10_ride                                 2.73500153213254e-06\n",
       "IsRouteSeattle_10_ride:is_peak_10_ride          1.19454364868092e-28\n",
       "post_hov:is_peak_10_ride                        1.88090135317251e-13\n",
       "post_hov:IsRouteSeattle_10_ride:is_peak_10_ride 0.00263932594521174 \n",
       "                                                r2                N      \n",
       "post_hov:IsRouteSeattle_10_ride                 0.304835246011862 1792156\n",
       "is_peak_10_ride                                 0.304835246011862 1792156\n",
       "IsRouteSeattle_10_ride:is_peak_10_ride          0.304835246011862 1792156\n",
       "post_hov:is_peak_10_ride                        0.304835246011862 1792156\n",
       "post_hov:IsRouteSeattle_10_ride:is_peak_10_ride 0.304835246011862 1792156\n",
       "                                                granularity       \n",
       "post_hov:IsRouteSeattle_10_ride                 rider/date/commute\n",
       "is_peak_10_ride                                 rider/date/commute\n",
       "IsRouteSeattle_10_ride:is_peak_10_ride          rider/date/commute\n",
       "post_hov:is_peak_10_ride                        rider/date/commute\n",
       "post_hov:IsRouteSeattle_10_ride:is_peak_10_ride rider/date/commute"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "\n",
    "(table3_model2 = fit_ridership_logit_models(data = commute_ride_data,\n",
    "                        predictors=c(\"post_hov:IsRouteSeattle_10_ride\",\n",
    "                                        \"is_peak_10_ride\",\n",
    "                                        \"IsRouteSeattle_10_ride:is_peak_10_ride\",\n",
    "                                        \"post_hov:is_peak_10_ride\",\n",
    "                                        \"post_hov:IsRouteSeattle_10_ride:is_peak_10_ride\"\n",
    "                                ),\n",
    "                        model=2,\n",
    "                        adjust_for=c(\"imputed_new_buses + AfternoonId + fDate\",\n",
    "                                        \"f_commutes_since_last_ride\",\n",
    "                                        \"f_favorite_route\"),\n",
    "                        granularity=\"rider/date/commute\"))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "===============================================\n",
      "Model  3 :\n",
      "===============================================\n",
      "\n",
      "\n",
      "Coefficients from Linear model (adjust_for effects omitted):\n",
      "    Estimate   Std. Error      t value     Pr(>|t|) \n",
      "1.607587e-02 1.906387e-03 8.432639e+00 3.385329e-17 \n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<table>\n",
       "<thead><tr><th scope=col>model</th><th scope=col>Estimate</th><th scope=col>Std. Error</th><th scope=col>t value</th><th scope=col>Pr(&gt;|t|)</th><th scope=col>r2</th><th scope=col>N</th><th scope=col>granularity</th></tr></thead>\n",
       "<tbody>\n",
       "\t<tr><td>3                                              </td><td>0.0160758731670565                             </td><td>0.00190638697207982                            </td><td>8.43263901951561                               </td><td>3.38532917887041e-17                           </td><td>0.326504398075457                              </td><td>762048                                         </td><td>rider/date/commute [first stop prefered riders]</td></tr>\n",
       "</tbody>\n",
       "</table>\n"
      ],
      "text/latex": [
       "\\begin{tabular}{llllllll}\n",
       " model & Estimate & Std. Error & t value & Pr(>\\textbar{}t\\textbar{}) & r2 & N & granularity\\\\\n",
       "\\hline\n",
       "\t 3                                                   & 0.0160758731670565                                  & 0.00190638697207982                                 & 8.43263901951561                                    & 3.38532917887041e-17                                & 0.326504398075457                                   & 762048                                              & rider/date/commute {[}first stop prefered riders{]}\\\\\n",
       "\\end{tabular}\n"
      ],
      "text/markdown": [
       "\n",
       "| model | Estimate | Std. Error | t value | Pr(>|t|) | r2 | N | granularity |\n",
       "|---|---|---|---|---|---|---|---|\n",
       "| 3                                               | 0.0160758731670565                              | 0.00190638697207982                             | 8.43263901951561                                | 3.38532917887041e-17                            | 0.326504398075457                               | 762048                                          | rider/date/commute [first stop prefered riders] |\n",
       "\n"
      ],
      "text/plain": [
       "     model Estimate           Std. Error          t value         \n",
       "[1,] 3     0.0160758731670565 0.00190638697207982 8.43263901951561\n",
       "     Pr(>|t|)             r2                N     \n",
       "[1,] 3.38532917887041e-17 0.326504398075457 762048\n",
       "     granularity                                    \n",
       "[1,] rider/date/commute [first stop prefered riders]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "\n",
    "(table3_model3 = fit_ridership_logit_models(data = commute_ride_data[first_stop_10_ride >= 0.5],\n",
    "                        predictors=c(\"post_hov:IsRouteSeattle_10_ride\"),\n",
    "                        adjust_for=c(\"imputed_new_buses\",\n",
    "                                        \"fDate\",\n",
    "                                        \"f_commutes_since_last_ride\",\n",
    "                                        \"f_favorite_route\"),\n",
    "                        model=3,\n",
    "                        granularity=\"rider/date/commute [first stop prefered riders]\"))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "===============================================\n",
      "Model  4 :\n",
      "===============================================\n",
      "\n",
      "\n",
      "Coefficients from Linear model (adjust_for effects omitted):\n",
      "    Estimate   Std. Error      t value     Pr(>|t|) \n",
      "1.930788e-02 1.549990e-03 1.245678e+01 1.291005e-35 \n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<table>\n",
       "<thead><tr><th scope=col>model</th><th scope=col>Estimate</th><th scope=col>Std. Error</th><th scope=col>t value</th><th scope=col>Pr(&gt;|t|)</th><th scope=col>r2</th><th scope=col>N</th><th scope=col>granularity</th></tr></thead>\n",
       "<tbody>\n",
       "\t<tr><td>4                                             </td><td>0.0193078817255487                            </td><td>0.00154999001960853                           </td><td>12.4567780961745                              </td><td>1.29100465638727e-35                          </td><td>0.316377266684956                             </td><td>1218882                                       </td><td>rider/date/commute [last stop prefered riders]</td></tr>\n",
       "</tbody>\n",
       "</table>\n"
      ],
      "text/latex": [
       "\\begin{tabular}{llllllll}\n",
       " model & Estimate & Std. Error & t value & Pr(>\\textbar{}t\\textbar{}) & r2 & N & granularity\\\\\n",
       "\\hline\n",
       "\t 4                                                  & 0.0193078817255487                                 & 0.00154999001960853                                & 12.4567780961745                                   & 1.29100465638727e-35                               & 0.316377266684956                                  & 1218882                                            & rider/date/commute {[}last stop prefered riders{]}\\\\\n",
       "\\end{tabular}\n"
      ],
      "text/markdown": [
       "\n",
       "| model | Estimate | Std. Error | t value | Pr(>|t|) | r2 | N | granularity |\n",
       "|---|---|---|---|---|---|---|---|\n",
       "| 4                                              | 0.0193078817255487                             | 0.00154999001960853                            | 12.4567780961745                               | 1.29100465638727e-35                           | 0.316377266684956                              | 1218882                                        | rider/date/commute [last stop prefered riders] |\n",
       "\n"
      ],
      "text/plain": [
       "     model Estimate           Std. Error          t value         \n",
       "[1,] 4     0.0193078817255487 0.00154999001960853 12.4567780961745\n",
       "     Pr(>|t|)             r2                N      \n",
       "[1,] 1.29100465638727e-35 0.316377266684956 1218882\n",
       "     granularity                                   \n",
       "[1,] rider/date/commute [last stop prefered riders]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "\n",
    "(table3_model4 = fit_ridership_logit_models(data = commute_ride_data[last_stop_10_ride >= 0.5],\n",
    "                        predictors=c(\"post_hov:IsRouteSeattle_10_ride\"),\n",
    "                        adjust_for=c(\"imputed_new_buses\",\n",
    "                                        \"fDate\",\n",
    "                                        \"f_commutes_since_last_ride\",\n",
    "                                        \"f_favorite_route\"),\n",
    "                        model=4,\n",
    "                        granularity=\"rider/date/commute [last stop prefered riders]\"))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "===============================================\n",
      "Model  5 :\n",
      "===============================================\n",
      "\n",
      "\n",
      "Coefficients from Linear model (adjust_for effects omitted):\n",
      "   Estimate  Std. Error     t value    Pr(>|t|) \n",
      "0.004685415 0.002114822 2.215512444 0.026725241 \n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<table>\n",
       "<thead><tr><th scope=col>model</th><th scope=col>Estimate</th><th scope=col>Std. Error</th><th scope=col>t value</th><th scope=col>Pr(&gt;|t|)</th><th scope=col>r2</th><th scope=col>N</th><th scope=col>granularity</th></tr></thead>\n",
       "<tbody>\n",
       "\t<tr><td>5                  </td><td>0.00468541479446172</td><td>0.00211482215206419</td><td>2.21551244386602   </td><td>0.0267252412082117 </td><td>0.319069912690138  </td><td>679992             </td><td>ride/date/commute  </td></tr>\n",
       "</tbody>\n",
       "</table>\n"
      ],
      "text/latex": [
       "\\begin{tabular}{llllllll}\n",
       " model & Estimate & Std. Error & t value & Pr(>\\textbar{}t\\textbar{}) & r2 & N & granularity\\\\\n",
       "\\hline\n",
       "\t 5                   & 0.00468541479446172 & 0.00211482215206419 & 2.21551244386602    & 0.0267252412082117  & 0.319069912690138   & 679992              & ride/date/commute  \\\\\n",
       "\\end{tabular}\n"
      ],
      "text/markdown": [
       "\n",
       "| model | Estimate | Std. Error | t value | Pr(>|t|) | r2 | N | granularity |\n",
       "|---|---|---|---|---|---|---|---|\n",
       "| 5                   | 0.00468541479446172 | 0.00211482215206419 | 2.21551244386602    | 0.0267252412082117  | 0.319069912690138   | 679992              | ride/date/commute   |\n",
       "\n"
      ],
      "text/plain": [
       "     model Estimate            Std. Error          t value         \n",
       "[1,] 5     0.00468541479446172 0.00211482215206419 2.21551244386602\n",
       "     Pr(>|t|)           r2                N      granularity      \n",
       "[1,] 0.0267252412082117 0.319069912690138 679992 ride/date/commute"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "\n",
    "(table3_model5 = fit_ridership_logit_models(data = commute_ride_data[date >= as.Date(\"2016-03-01\") & \n",
    "                                                        date < as.Date(\"2016-07-01\")],\n",
    "                        predictors=c(\"post_hov:IsRouteSeattle_10_ride\"),\n",
    "                        adjust_for=c(\"imputed_new_buses\",\n",
    "                                        \"fDate\",\n",
    "                                        \"f_commutes_since_last_ride\",\n",
    "                                        \"f_favorite_route\"),\n",
    "                        model=5,\n",
    "                        granularity=\"ride/date/commute\"))\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Table 3 Summary Statistics"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "2"
      ],
      "text/latex": [
       "2"
      ],
      "text/markdown": [
       "2"
      ],
      "text/plain": [
       "[1] 2"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<table>\n",
       "<thead><tr><th></th><th scope=col>model</th><th scope=col>Estimate</th><th scope=col>Std. Error</th><th scope=col>t value</th><th scope=col>Pr(&gt;|t|)</th><th scope=col>r2</th><th scope=col>N</th><th scope=col>granularity</th></tr></thead>\n",
       "<tbody>\n",
       "\t<tr><th scope=row></th><td>1                                              </td><td>0.0183834420658064                             </td><td>0.00131235215593952                            </td><td>14.0080099557162                               </td><td>1.40010244000293e-44                           </td><td>0.3044796455947                                </td><td>1792156                                        </td><td>rider/date/commute                             </td></tr>\n",
       "\t<tr><th scope=row>post_hov:IsRouteSeattle_10_ride</th><td>2                                              </td><td>0.00963893724650586                            </td><td>0.00281647234222826                            </td><td>3.42234400884618                               </td><td>0.000620850962943762                           </td><td>0.304835246011862                              </td><td>1792156                                        </td><td>rider/date/commute                             </td></tr>\n",
       "\t<tr><th scope=row>is_peak_10_ride</th><td>2                                              </td><td>0.00972450904195021                            </td><td>0.00207354709992748                            </td><td>4.68979414178261                               </td><td>2.73500153213254e-06                           </td><td>0.304835246011862                              </td><td>1792156                                        </td><td>rider/date/commute                             </td></tr>\n",
       "\t<tr><th scope=row>IsRouteSeattle_10_ride:is_peak_10_ride</th><td>2                                              </td><td>0.0278229201357811                             </td><td>0.00250553908896106                            </td><td>11.1045643863086                               </td><td>1.19454364868092e-28                           </td><td>0.304835246011862                              </td><td>1792156                                        </td><td>rider/date/commute                             </td></tr>\n",
       "\t<tr><th scope=row>post_hov:is_peak_10_ride</th><td>2                                              </td><td>-0.0241366870506926                            </td><td>0.00328075346524461                            </td><td>-7.3570560258154                               </td><td>1.88090135317251e-13                           </td><td>0.304835246011862                              </td><td>1792156                                        </td><td>rider/date/commute                             </td></tr>\n",
       "\t<tr><th scope=row>post_hov:IsRouteSeattle_10_ride:is_peak_10_ride</th><td>2                                              </td><td>0.0120185839852569                             </td><td>0.00399700518418931                            </td><td>3.00689727218718                               </td><td>0.00263932594521174                            </td><td>0.304835246011862                              </td><td>1792156                                        </td><td>rider/date/commute                             </td></tr>\n",
       "\t<tr><th scope=row></th><td>3                                              </td><td>0.0160758731670565                             </td><td>0.00190638697207982                            </td><td>8.43263901951561                               </td><td>3.38532917887041e-17                           </td><td>0.326504398075457                              </td><td>762048                                         </td><td>rider/date/commute [first stop prefered riders]</td></tr>\n",
       "\t<tr><th scope=row></th><td>4                                              </td><td>0.0193078817255487                             </td><td>0.00154999001960853                            </td><td>12.4567780961745                               </td><td>1.29100465638727e-35                           </td><td>0.316377266684956                              </td><td>1218882                                        </td><td>rider/date/commute [last stop prefered riders] </td></tr>\n",
       "\t<tr><th scope=row></th><td>5                                              </td><td>0.00468541479446172                            </td><td>0.00211482215206419                            </td><td>2.21551244386602                               </td><td>0.0267252412082117                             </td><td>0.319069912690138                              </td><td>679992                                         </td><td>ride/date/commute                              </td></tr>\n",
       "</tbody>\n",
       "</table>\n"
      ],
      "text/latex": [
       "\\begin{tabular}{r|llllllll}\n",
       "  & model & Estimate & Std. Error & t value & Pr(>\\textbar{}t\\textbar{}) & r2 & N & granularity\\\\\n",
       "\\hline\n",
       "\t & 1                                               & 0.0183834420658064                              & 0.00131235215593952                             & 14.0080099557162                                & 1.40010244000293e-44                            & 0.3044796455947                                 & 1792156                                         & rider/date/commute                             \\\\\n",
       "\tpost\\_hov:IsRouteSeattle\\_10\\_ride & 2                                               & 0.00963893724650586                             & 0.00281647234222826                             & 3.42234400884618                                & 0.000620850962943762                            & 0.304835246011862                               & 1792156                                         & rider/date/commute                             \\\\\n",
       "\tis\\_peak\\_10\\_ride & 2                                               & 0.00972450904195021                             & 0.00207354709992748                             & 4.68979414178261                                & 2.73500153213254e-06                            & 0.304835246011862                               & 1792156                                         & rider/date/commute                             \\\\\n",
       "\tIsRouteSeattle\\_10\\_ride:is\\_peak\\_10\\_ride & 2                                               & 0.0278229201357811                              & 0.00250553908896106                             & 11.1045643863086                                & 1.19454364868092e-28                            & 0.304835246011862                               & 1792156                                         & rider/date/commute                             \\\\\n",
       "\tpost\\_hov:is\\_peak\\_10\\_ride & 2                                               & -0.0241366870506926                             & 0.00328075346524461                             & -7.3570560258154                                & 1.88090135317251e-13                            & 0.304835246011862                               & 1792156                                         & rider/date/commute                             \\\\\n",
       "\tpost\\_hov:IsRouteSeattle\\_10\\_ride:is\\_peak\\_10\\_ride & 2                                               & 0.0120185839852569                              & 0.00399700518418931                             & 3.00689727218718                                & 0.00263932594521174                             & 0.304835246011862                               & 1792156                                         & rider/date/commute                             \\\\\n",
       "\t & 3                                                   & 0.0160758731670565                                  & 0.00190638697207982                                 & 8.43263901951561                                    & 3.38532917887041e-17                                & 0.326504398075457                                   & 762048                                              & rider/date/commute {[}first stop prefered riders{]}\\\\\n",
       "\t & 4                                                   & 0.0193078817255487                                  & 0.00154999001960853                                 & 12.4567780961745                                    & 1.29100465638727e-35                                & 0.316377266684956                                   & 1218882                                             & rider/date/commute {[}last stop prefered riders{]} \\\\\n",
       "\t & 5                                               & 0.00468541479446172                             & 0.00211482215206419                             & 2.21551244386602                                & 0.0267252412082117                              & 0.319069912690138                               & 679992                                          & ride/date/commute                              \\\\\n",
       "\\end{tabular}\n"
      ],
      "text/markdown": [
       "\n",
       "| <!--/--> | model | Estimate | Std. Error | t value | Pr(>|t|) | r2 | N | granularity |\n",
       "|---|---|---|---|---|---|---|---|---|\n",
       "|  | 1                                               | 0.0183834420658064                              | 0.00131235215593952                             | 14.0080099557162                                | 1.40010244000293e-44                            | 0.3044796455947                                 | 1792156                                         | rider/date/commute                              |\n",
       "| post_hov:IsRouteSeattle_10_ride | 2                                               | 0.00963893724650586                             | 0.00281647234222826                             | 3.42234400884618                                | 0.000620850962943762                            | 0.304835246011862                               | 1792156                                         | rider/date/commute                              |\n",
       "| is_peak_10_ride | 2                                               | 0.00972450904195021                             | 0.00207354709992748                             | 4.68979414178261                                | 2.73500153213254e-06                            | 0.304835246011862                               | 1792156                                         | rider/date/commute                              |\n",
       "| IsRouteSeattle_10_ride:is_peak_10_ride | 2                                               | 0.0278229201357811                              | 0.00250553908896106                             | 11.1045643863086                                | 1.19454364868092e-28                            | 0.304835246011862                               | 1792156                                         | rider/date/commute                              |\n",
       "| post_hov:is_peak_10_ride | 2                                               | -0.0241366870506926                             | 0.00328075346524461                             | -7.3570560258154                                | 1.88090135317251e-13                            | 0.304835246011862                               | 1792156                                         | rider/date/commute                              |\n",
       "| post_hov:IsRouteSeattle_10_ride:is_peak_10_ride | 2                                               | 0.0120185839852569                              | 0.00399700518418931                             | 3.00689727218718                                | 0.00263932594521174                             | 0.304835246011862                               | 1792156                                         | rider/date/commute                              |\n",
       "|  | 3                                               | 0.0160758731670565                              | 0.00190638697207982                             | 8.43263901951561                                | 3.38532917887041e-17                            | 0.326504398075457                               | 762048                                          | rider/date/commute [first stop prefered riders] |\n",
       "|  | 4                                               | 0.0193078817255487                              | 0.00154999001960853                             | 12.4567780961745                                | 1.29100465638727e-35                            | 0.316377266684956                               | 1218882                                         | rider/date/commute [last stop prefered riders]  |\n",
       "|  | 5                                               | 0.00468541479446172                             | 0.00211482215206419                             | 2.21551244386602                                | 0.0267252412082117                              | 0.319069912690138                               | 679992                                          | ride/date/commute                               |\n",
       "\n"
      ],
      "text/plain": [
       "                                                model Estimate           \n",
       "                                                1     0.0183834420658064 \n",
       "post_hov:IsRouteSeattle_10_ride                 2     0.00963893724650586\n",
       "is_peak_10_ride                                 2     0.00972450904195021\n",
       "IsRouteSeattle_10_ride:is_peak_10_ride          2     0.0278229201357811 \n",
       "post_hov:is_peak_10_ride                        2     -0.0241366870506926\n",
       "post_hov:IsRouteSeattle_10_ride:is_peak_10_ride 2     0.0120185839852569 \n",
       "                                                3     0.0160758731670565 \n",
       "                                                4     0.0193078817255487 \n",
       "                                                5     0.00468541479446172\n",
       "                                                Std. Error         \n",
       "                                                0.00131235215593952\n",
       "post_hov:IsRouteSeattle_10_ride                 0.00281647234222826\n",
       "is_peak_10_ride                                 0.00207354709992748\n",
       "IsRouteSeattle_10_ride:is_peak_10_ride          0.00250553908896106\n",
       "post_hov:is_peak_10_ride                        0.00328075346524461\n",
       "post_hov:IsRouteSeattle_10_ride:is_peak_10_ride 0.00399700518418931\n",
       "                                                0.00190638697207982\n",
       "                                                0.00154999001960853\n",
       "                                                0.00211482215206419\n",
       "                                                t value         \n",
       "                                                14.0080099557162\n",
       "post_hov:IsRouteSeattle_10_ride                 3.42234400884618\n",
       "is_peak_10_ride                                 4.68979414178261\n",
       "IsRouteSeattle_10_ride:is_peak_10_ride          11.1045643863086\n",
       "post_hov:is_peak_10_ride                        -7.3570560258154\n",
       "post_hov:IsRouteSeattle_10_ride:is_peak_10_ride 3.00689727218718\n",
       "                                                8.43263901951561\n",
       "                                                12.4567780961745\n",
       "                                                2.21551244386602\n",
       "                                                Pr(>|t|)            \n",
       "                                                1.40010244000293e-44\n",
       "post_hov:IsRouteSeattle_10_ride                 0.000620850962943762\n",
       "is_peak_10_ride                                 2.73500153213254e-06\n",
       "IsRouteSeattle_10_ride:is_peak_10_ride          1.19454364868092e-28\n",
       "post_hov:is_peak_10_ride                        1.88090135317251e-13\n",
       "post_hov:IsRouteSeattle_10_ride:is_peak_10_ride 0.00263932594521174 \n",
       "                                                3.38532917887041e-17\n",
       "                                                1.29100465638727e-35\n",
       "                                                0.0267252412082117  \n",
       "                                                r2                N      \n",
       "                                                0.3044796455947   1792156\n",
       "post_hov:IsRouteSeattle_10_ride                 0.304835246011862 1792156\n",
       "is_peak_10_ride                                 0.304835246011862 1792156\n",
       "IsRouteSeattle_10_ride:is_peak_10_ride          0.304835246011862 1792156\n",
       "post_hov:is_peak_10_ride                        0.304835246011862 1792156\n",
       "post_hov:IsRouteSeattle_10_ride:is_peak_10_ride 0.304835246011862 1792156\n",
       "                                                0.326504398075457 762048 \n",
       "                                                0.316377266684956 1218882\n",
       "                                                0.319069912690138 679992 \n",
       "                                                granularity                                    \n",
       "                                                rider/date/commute                             \n",
       "post_hov:IsRouteSeattle_10_ride                 rider/date/commute                             \n",
       "is_peak_10_ride                                 rider/date/commute                             \n",
       "IsRouteSeattle_10_ride:is_peak_10_ride          rider/date/commute                             \n",
       "post_hov:is_peak_10_ride                        rider/date/commute                             \n",
       "post_hov:IsRouteSeattle_10_ride:is_peak_10_ride rider/date/commute                             \n",
       "                                                rider/date/commute [first stop prefered riders]\n",
       "                                                rider/date/commute [last stop prefered riders] \n",
       "                                                ride/date/commute                              "
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "1 + 1\n",
    "rbind( table3_model1,\n",
    "       table3_model2,\n",
    "       table3_model3,\n",
    "       table3_model4,\n",
    "       table3_model5)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Fit the Models for Table 4"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "===============================================\n",
      "Model  1 :\n",
      "===============================================\n",
      "\n",
      "\n",
      "Coefficients from Linear model (adjust_for effects omitted):\n",
      "    Estimate   Std. Error      t value     Pr(>|t|) \n",
      "2.986884e-02 5.994643e-03 4.982588e+00 6.283883e-07 \n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<table>\n",
       "<thead><tr><th scope=col>model</th><th scope=col>Estimate</th><th scope=col>Std. Error</th><th scope=col>t value</th><th scope=col>Pr(&gt;|t|)</th><th scope=col>r2</th><th scope=col>N</th><th scope=col>granularity</th></tr></thead>\n",
       "<tbody>\n",
       "\t<tr><td>1                                                </td><td>0.0298688411596996                               </td><td>0.00599464349979669                              </td><td>4.98258839924554                                 </td><td>6.28388268823966e-07                             </td><td>0.323916300249459                                </td><td>105112                                           </td><td>rider/date/commute [Single Stop Preferred Riders]</td></tr>\n",
       "</tbody>\n",
       "</table>\n"
      ],
      "text/latex": [
       "\\begin{tabular}{llllllll}\n",
       " model & Estimate & Std. Error & t value & Pr(>\\textbar{}t\\textbar{}) & r2 & N & granularity\\\\\n",
       "\\hline\n",
       "\t 1                                                     & 0.0298688411596996                                    & 0.00599464349979669                                   & 4.98258839924554                                      & 6.28388268823966e-07                                  & 0.323916300249459                                     & 105112                                                & rider/date/commute {[}Single Stop Preferred Riders{]}\\\\\n",
       "\\end{tabular}\n"
      ],
      "text/markdown": [
       "\n",
       "| model | Estimate | Std. Error | t value | Pr(>|t|) | r2 | N | granularity |\n",
       "|---|---|---|---|---|---|---|---|\n",
       "| 1                                                 | 0.0298688411596996                                | 0.00599464349979669                               | 4.98258839924554                                  | 6.28388268823966e-07                              | 0.323916300249459                                 | 105112                                            | rider/date/commute [Single Stop Preferred Riders] |\n",
       "\n"
      ],
      "text/plain": [
       "     model Estimate           Std. Error          t value         \n",
       "[1,] 1     0.0298688411596996 0.00599464349979669 4.98258839924554\n",
       "     Pr(>|t|)             r2                N     \n",
       "[1,] 6.28388268823966e-07 0.323916300249459 105112\n",
       "     granularity                                      \n",
       "[1,] rider/date/commute [Single Stop Preferred Riders]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "(T4_M1 = fit_ridership_logit_models(data = commute_ride_data[(!SR520WBHOV) &  (!SR520EBHOV) & (single_stop_10_ride >= 0.5)],\n",
    "                            predictors=c(\"imputed_new_buses\"),\n",
    "                            adjust_for=c(\"fDate\",\n",
    "                                            \"f_commutes_since_last_ride\",\n",
    "                                           \"f_favorite_route\" ),\n",
    "                            model=1,\n",
    "                            granularity=\"rider/date/commute [Single Stop Preferred Riders]\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "===============================================\n",
      "Model  2 :\n",
      "===============================================\n",
      "\n",
      "\n",
      "Coefficients from Linear model (adjust_for effects omitted):\n",
      "                                         Estimate  Std. Error   t value\n",
      "imputed_new_buses                     -0.01420607 0.001969738 -7.212162\n",
      "imputed_new_buses:single_stop_10_ride  0.01052608 0.004478290  2.350468\n",
      "                                          Pr(>|t|)\n",
      "imputed_new_buses                     5.510546e-13\n",
      "imputed_new_buses:single_stop_10_ride 1.874999e-02\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<table>\n",
       "<thead><tr><th></th><th scope=col>model</th><th scope=col>Estimate</th><th scope=col>Std. Error</th><th scope=col>t value</th><th scope=col>Pr(&gt;|t|)</th><th scope=col>r2</th><th scope=col>N</th><th scope=col>granularity</th></tr></thead>\n",
       "<tbody>\n",
       "\t<tr><th scope=row>imputed_new_buses</th><td>2                   </td><td>-0.0142060705128649 </td><td>0.00196973814872917 </td><td>-7.21216194245429   </td><td>5.51054556827356e-13</td><td>0.283597428423704   </td><td>1104348             </td><td>rider/date/commute  </td></tr>\n",
       "\t<tr><th scope=row>imputed_new_buses:single_stop_10_ride</th><td>2                   </td><td>0.0105260770725664  </td><td>0.00447828987811743 </td><td>2.35046800431581    </td><td>0.0187499945174823  </td><td>0.283597428423704   </td><td>1104348             </td><td>rider/date/commute  </td></tr>\n",
       "</tbody>\n",
       "</table>\n"
      ],
      "text/latex": [
       "\\begin{tabular}{r|llllllll}\n",
       "  & model & Estimate & Std. Error & t value & Pr(>\\textbar{}t\\textbar{}) & r2 & N & granularity\\\\\n",
       "\\hline\n",
       "\timputed\\_new\\_buses & 2                    & -0.0142060705128649  & 0.00196973814872917  & -7.21216194245429    & 5.51054556827356e-13 & 0.283597428423704    & 1104348              & rider/date/commute  \\\\\n",
       "\timputed\\_new\\_buses:single\\_stop\\_10\\_ride & 2                    & 0.0105260770725664   & 0.00447828987811743  & 2.35046800431581     & 0.0187499945174823   & 0.283597428423704    & 1104348              & rider/date/commute  \\\\\n",
       "\\end{tabular}\n"
      ],
      "text/markdown": [
       "\n",
       "| <!--/--> | model | Estimate | Std. Error | t value | Pr(>|t|) | r2 | N | granularity |\n",
       "|---|---|---|---|---|---|---|---|---|\n",
       "| imputed_new_buses | 2                    | -0.0142060705128649  | 0.00196973814872917  | -7.21216194245429    | 5.51054556827356e-13 | 0.283597428423704    | 1104348              | rider/date/commute   |\n",
       "| imputed_new_buses:single_stop_10_ride | 2                    | 0.0105260770725664   | 0.00447828987811743  | 2.35046800431581     | 0.0187499945174823   | 0.283597428423704    | 1104348              | rider/date/commute   |\n",
       "\n"
      ],
      "text/plain": [
       "                                      model Estimate           \n",
       "imputed_new_buses                     2     -0.0142060705128649\n",
       "imputed_new_buses:single_stop_10_ride 2     0.0105260770725664 \n",
       "                                      Std. Error          t value          \n",
       "imputed_new_buses                     0.00196973814872917 -7.21216194245429\n",
       "imputed_new_buses:single_stop_10_ride 0.00447828987811743 2.35046800431581 \n",
       "                                      Pr(>|t|)             r2               \n",
       "imputed_new_buses                     5.51054556827356e-13 0.283597428423704\n",
       "imputed_new_buses:single_stop_10_ride 0.0187499945174823   0.283597428423704\n",
       "                                      N       granularity       \n",
       "imputed_new_buses                     1104348 rider/date/commute\n",
       "imputed_new_buses:single_stop_10_ride 1104348 rider/date/commute"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "(T4_M2 = fit_ridership_logit_models(data = commute_ride_data[(!SR520WBHOV) &  (!SR520EBHOV)],\n",
    "                            predictors=c(\"imputed_new_buses\",\n",
    "                                            \"imputed_new_buses:single_stop_10_ride\"\n",
    "                                        ),\n",
    "                            adjust_for=c(\"imputed_new_buses + fDate\",\n",
    "                                            \"f_commutes_since_last_ride\",\n",
    "                                            \"f_favorite_route\"),\n",
    "                            model=2,\n",
    "                            granularity=\"rider/date/commute\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "===============================================\n",
      "Model  3 :\n",
      "===============================================\n",
      "\n",
      "\n",
      "Coefficients from Linear model (adjust_for effects omitted):\n",
      "\n",
      "=------------------------======================\n",
      "did_ride ~ imputed_new_buses + Is405North_10_ride:I405HOV + imputed_new_buses:I405HOV + \n",
      "    imputed_new_buses:Is405North_10_ride + imputed_new_buses:Is405North_10_ride:I405HOV + \n",
      "    imputed_new_buses + fDate + f_commutes_since_last_ride + \n",
      "    f_favorite_route\n",
      "<environment: 0x00000000057a15d0>\n",
      "                                          Estimate  Std. Error      t value\n",
      "(Intercept)                           0.6313461904 0.006490275   97.2757298\n",
      "imputed_new_buses                    -0.0052601299 0.002081203   -2.5274474\n",
      "fDate2015-09-03                      -0.0008318009 0.008352279   -0.0995897\n",
      "fDate2015-09-04                      -0.0856849913 0.008195422  -10.4552266\n",
      "fDate2015-09-08                       0.0474262420 0.008132423    5.8317479\n",
      "fDate2015-09-09                       0.0235563951 0.008029790    2.9336251\n",
      "fDate2015-09-10                       0.0131120888 0.007965367    1.6461375\n",
      "fDate2015-09-11                      -0.0433719780 0.007929057   -5.4700045\n",
      "fDate2015-09-14                       0.0616885776 0.007902670    7.8060424\n",
      "fDate2015-09-15                       0.0285652337 0.007865262    3.6318222\n",
      "fDate2015-09-16                       0.0237752551 0.007848004    3.0294652\n",
      "fDate2015-09-17                       0.0317254398 0.007833336    4.0500549\n",
      "fDate2015-09-18                      -0.0108725355 0.007821555   -1.3900734\n",
      "fDate2015-09-21                       0.0659519704 0.007811896    8.4425046\n",
      "fDate2015-09-22                       0.0441603391 0.007803716    5.6588862\n",
      "fDate2015-09-23                      -0.0208448178 0.007797922   -2.6731247\n",
      "fDate2015-09-24                       0.0490624380 0.007799092    6.2907884\n",
      "fDate2015-09-25                      -0.0045142999 0.007798954   -0.5788340\n",
      "fDate2015-09-28                       0.0654802089 0.007798823    8.3961656\n",
      "fDate2015-09-29                       0.0528383941 0.007796935    6.7768164\n",
      "fDate2015-09-30                       0.0415582090 0.007797481    5.3296964\n",
      "fDate2015-10-01                       0.0354999808 0.007797622    4.5526673\n",
      "fDate2015-10-02                      -0.0110860418 0.007799187   -1.4214355\n",
      "fDate2015-10-05                       0.0603657208 0.007800542    7.7386571\n",
      "fDate2015-10-06                       0.0494005269 0.007797562    6.3353808\n",
      "fDate2015-10-07                       0.0397258268 0.007797938    5.0944017\n",
      "fDate2015-10-08                       0.0408414062 0.007798171    5.2373058\n",
      "fDate2015-10-09                      -0.0479617750 0.007802627   -6.1468752\n",
      "fDate2015-10-12                       0.0666269703 0.007800358    8.5415272\n",
      "fDate2015-10-13                       0.0472581893 0.007798477    6.0599253\n",
      "fDate2015-10-14                       0.0256474320 0.007799939    3.2881580\n",
      "fDate2015-10-15                       0.0439930743 0.007800168    5.6400161\n",
      "fDate2015-10-16                      -0.0089432402 0.007801717   -1.1463169\n",
      "fDate2015-10-19                       0.0779949824 0.007802361    9.9963309\n",
      "fDate2015-10-20                       0.0562653328 0.007800838    7.2127294\n",
      "fDate2015-10-21                       0.0384210025 0.007803204    4.9237472\n",
      "fDate2015-10-22                       0.0241821842 0.007805628    3.0980449\n",
      "fDate2015-10-23                      -0.0179580690 0.007809815   -2.2994232\n",
      "fDate2015-10-26                       0.0701721824 0.007812077    8.9825254\n",
      "fDate2015-10-27                       0.0521744606 0.007810832    6.6797569\n",
      "fDate2015-10-28                       0.0446305005 0.007813442    5.7120154\n",
      "fDate2015-10-29                       0.0483171334 0.007815742    6.1820274\n",
      "fDate2015-10-30                       0.0016909842 0.007818621    0.2162765\n",
      "fDate2015-11-02                       0.0768439083 0.007821254    9.8250112\n",
      "fDate2015-11-03                       0.0621323230 0.007819873    7.9454389\n",
      "fDate2015-11-04                       0.0488625783 0.007821301    6.2473720\n",
      "fDate2015-11-05                       0.0542085508 0.007824098    6.9284090\n",
      "fDate2015-11-06                      -0.0028879223 0.007827972   -0.3689234\n",
      "fDate2015-11-09                       0.0802395680 0.007829319   10.2486012\n",
      "fDate2015-11-10                       0.0672942532 0.007829830    8.5945990\n",
      "fDate2015-11-11                       0.0396217021 0.007832517    5.0586169\n",
      "fDate2015-11-12                       0.0445818809 0.007835543    5.6896991\n",
      "fDate2015-11-13                       0.0098380205 0.007839456    1.2549367\n",
      "fDate2015-11-16                       0.0978814529 0.007841658   12.4822397\n",
      "fDate2015-11-17                       0.0522696877 0.007841860    6.6654710\n",
      "fDate2015-11-18                       0.0421572216 0.007845896    5.3731557\n",
      "fDate2015-11-19                       0.0513813053 0.007848020    6.5470405\n",
      "fDate2015-11-20                       0.0068070975 0.007849865    0.8671611\n",
      "fDate2015-11-23                      -0.0087528878 0.007854413   -1.1143911\n",
      "fDate2015-11-24                      -0.0092630594 0.007856880   -1.1789742\n",
      "fDate2015-11-25                      -0.0885489548 0.007861743  -11.2632727\n",
      "fDate2015-11-30                       0.1392160657 0.007859338   17.7134598\n",
      "fDate2015-12-01                       0.0736137095 0.007852879    9.3741051\n",
      "fDate2015-12-02                       0.0838412014 0.007850977   10.6790785\n",
      "fDate2015-12-03                       0.0413597632 0.007852589    5.2670224\n",
      "fDate2015-12-04                       0.0179361428 0.007854863    2.2834445\n",
      "fDate2015-12-07                       0.0627144005 0.007853869    7.9851601\n",
      "fDate2015-12-08                       0.0631591214 0.007852991    8.0426835\n",
      "fDate2015-12-09                       0.0421765665 0.007853450    5.3704508\n",
      "fDate2015-12-10                       0.0501175388 0.007854282    6.3809196\n",
      "fDate2015-12-11                       0.0128688556 0.007855126    1.6382748\n",
      "fDate2015-12-14                       0.0823859382 0.007855425   10.4877759\n",
      "fDate2015-12-15                       0.0473055956 0.007853560    6.0234587\n",
      "fDate2015-12-16                       0.0359127378 0.007854920    4.5720054\n",
      "fDate2015-12-17                       0.0444947593 0.007855949    5.6638303\n",
      "fDate2015-12-18                      -0.0380550181 0.007858616   -4.8424583\n",
      "fDate2016-01-04                       0.1666412285 0.007856226   21.2113587\n",
      "fDate2016-01-05                       0.1093055712 0.007851181   13.9221820\n",
      "fDate2016-01-06                       0.1002019665 0.007850999   12.7629580\n",
      "fDate2016-01-07                       0.1091842774 0.007851289   13.9065414\n",
      "fDate2016-01-08                       0.0844852913 0.007851971   10.7597552\n",
      "fDate2016-01-11                       0.1258123486 0.007852124   16.0227157\n",
      "fDate2016-01-12                       0.1096104672 0.007851104   13.9611533\n",
      "fDate2016-01-13                       0.1110750855 0.007851125   14.1476654\n",
      "fDate2016-01-14                       0.1171378889 0.007851446   14.9192766\n",
      "fDate2016-01-15                       0.0834224912 0.007854437   10.6210661\n",
      "fDate2016-01-19                       0.1290798316 0.007851954   16.4391978\n",
      "fDate2016-01-20                       0.1059226663 0.007851363   13.4909903\n",
      "fDate2016-01-21                       0.1094973946 0.007853907   13.9417742\n",
      "fDate2016-01-22                       0.0802151946 0.007851888   10.2160385\n",
      "fDate2016-01-25                       0.1240828998 0.007852660   15.8013836\n",
      "fDate2016-01-26                       0.1183162320 0.007851648   15.0689687\n",
      "fDate2016-01-27                       0.1135788788 0.007851493   14.4658955\n",
      "fDate2016-01-28                       0.1129783942 0.007851714   14.3890105\n",
      "fDate2016-01-29                       0.0889603995 0.007851942   11.3297328\n",
      "fDate2016-02-01                       0.0746284650 0.007853471    9.5026087\n",
      "fDate2016-02-02                       0.1008194057 0.007853262   12.8379024\n",
      "fDate2016-02-03                       0.1061645153 0.007851406   13.5217208\n",
      "fDate2016-02-04                       0.1111174000 0.007851369   14.1526142\n",
      "fDate2016-02-05                       0.0886026462 0.007851724   11.2844830\n",
      "fDate2016-02-08                       0.1287457644 0.007851474   16.3976552\n",
      "fDate2016-02-09                       0.0478869655 0.007851574    6.0990276\n",
      "fDate2016-02-10                       0.0328075820 0.007855075    4.1766095\n",
      "fDate2016-02-11                       0.0514161690 0.007855533    6.5452171\n",
      "fDate2016-02-12                      -0.0185635753 0.007856743   -2.3627571\n",
      "fDate2016-02-16                       0.0617066685 0.007858192    7.8525274\n",
      "fDate2016-02-17                       0.0553121606 0.007855915    7.0408302\n",
      "fDate2016-02-18                       0.0412197593 0.007856270    5.2467337\n",
      "fDate2016-02-19                       0.0142384281 0.007857511    1.8120787\n",
      "fDate2016-02-22                       0.0752540102 0.007857594    9.5772336\n",
      "fDate2016-02-23                       0.0734297973 0.007854947    9.3482232\n",
      "fDate2016-02-24                       0.0467127709 0.007854817    5.9470221\n",
      "fDate2016-02-25                       0.0479215607 0.007855806    6.1001455\n",
      "fDate2016-02-26                       0.0175849509 0.007856634    2.2382296\n",
      "fDate2016-02-29                       0.0844570861 0.007857276   10.7489010\n",
      "fDate2016-03-01                       0.0601221351 0.007854616    7.6543700\n",
      "fDate2016-03-02                       0.0672245681 0.007855140    8.5580361\n",
      "fDate2016-03-03                       0.0578459078 0.007855159    7.3640662\n",
      "fDate2016-03-04                       0.0186083864 0.007856664    2.3684843\n",
      "fDate2016-03-07                       0.0855536186 0.007856925   10.8889448\n",
      "fDate2016-03-08                       0.0679027618 0.007855341    8.6441521\n",
      "fDate2016-03-09                       0.0537315633 0.007856153    6.8394244\n",
      "fDate2016-03-10                       0.0501799588 0.007856606    6.3869762\n",
      "fDate2016-03-11                       0.0123665724 0.007857798    1.5737962\n",
      "fDate2016-03-14                       0.0707078038 0.007858259    8.9978971\n",
      "fDate2016-03-15                       0.0671663710 0.007856791    8.5488295\n",
      "fDate2016-03-16                       0.0602497175 0.007856865    7.6684169\n",
      "fDate2016-03-17                       0.0606046994 0.007857218    7.7132519\n",
      "fDate2016-03-18                       0.0071064563 0.007857933    0.9043671\n",
      "fDate2016-03-21                       0.1007114496 0.007858302   12.8159303\n",
      "fDate2016-03-22                       0.0750649326 0.007856243    9.5548134\n",
      "fDate2016-03-23                       0.0505774531 0.007857182    6.4370984\n",
      "fDate2016-03-24                       0.0639377768 0.007858464    8.1361667\n",
      "fDate2016-03-25                       0.0085621970 0.007859812    1.0893641\n",
      "fDate2016-03-28                       0.0773363719 0.007861308    9.8375955\n",
      "fDate2016-03-29                       0.0395591348 0.007860030    5.0329498\n",
      "fDate2016-03-30                       0.0577108253 0.007860427    7.3419454\n",
      "fDate2016-03-31                       0.0474915571 0.007861018    6.0414004\n",
      "fDate2016-04-01                       0.0010546519 0.007863446    0.1341208\n",
      "fDate2016-04-04                       0.0770727790 0.007864132    9.8005451\n",
      "fDate2016-04-05                       0.0670863373 0.007861494    8.5335359\n",
      "fDate2016-04-06                       0.0515551845 0.007861487    6.5579431\n",
      "fDate2016-04-07                       0.0358836917 0.007862217    4.5640677\n",
      "fDate2016-04-08                      -0.0125791242 0.007864556   -1.5994704\n",
      "f_commutes_since_last_ride2          -0.1969748927 0.001260712 -156.2410002\n",
      "f_commutes_since_last_ride3          -0.3242151563 0.001609505 -201.4378285\n",
      "f_commutes_since_last_ride4          -0.3668015791 0.001920076 -191.0349294\n",
      "f_commutes_since_last_ride5          -0.4311196260 0.002241157 -192.3647270\n",
      "f_commutes_since_last_ride6          -0.4470175499 0.002523133 -177.1676693\n",
      "f_commutes_since_last_ride7          -0.4904444702 0.002819763 -173.9310815\n",
      "f_commutes_since_last_ride8          -0.4886374623 0.003075410 -158.8853109\n",
      "f_commutes_since_last_ride9          -0.5162545515 0.003361244 -153.5903158\n",
      "f_commutes_since_last_ride10         -0.4709025828 0.003618851 -130.1248855\n",
      "f_commutes_since_last_ride11         -0.5548550224 0.004006654 -138.4833739\n",
      "f_commutes_since_last_ride12         -0.5546906490 0.004226101 -131.2535255\n",
      "f_commutes_since_last_ride13         -0.5658595397 0.004462754 -126.7960351\n",
      "f_commutes_since_last_ride14         -0.5612755928 0.004686530 -119.7635872\n",
      "f_commutes_since_last_ride15         -0.5741594707 0.004936953 -116.2983390\n",
      "f_commutes_since_last_ride16         -0.5748308491 0.005160926 -111.3813493\n",
      "f_commutes_since_last_ride17         -0.5799983609 0.005389111 -107.6241169\n",
      "f_commutes_since_last_ride18         -0.5831768498 0.005612178 -103.9127547\n",
      "f_commutes_since_last_ride19         -0.5859061295 0.005848036 -100.1885284\n",
      "f_commutes_since_last_ride20         -0.5706542468 0.006079211  -93.8697881\n",
      "f_commutes_since_last_ride21         -0.6118521165 0.006378649  -95.9218932\n",
      "f_commutes_since_last_ride22         -0.6045587145 0.006542604  -92.4033833\n",
      "f_commutes_since_last_ride23         -0.6091455094 0.006737080  -90.4168407\n",
      "f_commutes_since_last_ride24         -0.6036242703 0.006919051  -87.2409052\n",
      "f_commutes_since_last_ride25         -0.6177289850 0.007130843  -86.6277659\n",
      "f_commutes_since_last_ride26         -0.6096265029 0.007298197  -83.5311113\n",
      "f_commutes_since_last_ride27         -0.6095372528 0.007491994  -81.3584800\n",
      "f_commutes_since_last_ride28         -0.6168636667 0.007689619  -80.2203195\n",
      "f_commutes_since_last_ride29         -0.6255181500 0.007884857  -79.3315811\n",
      "f_commutes_since_last_ride30         -0.6129219361 0.008037179  -76.2608289\n",
      "f_commutes_since_last_ride31         -0.6342630879 0.008244920  -76.9277397\n",
      "f_commutes_since_last_ride32         -0.6297191628 0.008354700  -75.3730470\n",
      "f_commutes_since_last_ride33         -0.6339345819 0.008496797  -74.6086526\n",
      "f_commutes_since_last_ride34         -0.6325813416 0.008624548  -73.3466095\n",
      "f_commutes_since_last_ride35         -0.6401436404 0.008751910  -73.1433055\n",
      "f_commutes_since_last_ride36         -0.6369436726 0.008843131  -72.0269431\n",
      "f_commutes_since_last_ride37         -0.6404841061 0.008970167  -71.4015805\n",
      "f_commutes_since_last_ride38         -0.6304150224 0.009085750  -69.3850249\n",
      "f_commutes_since_last_ride39         -0.6415476008 0.009253487  -69.3303633\n",
      "f_commutes_since_last_ride40         -0.6557532424 0.001323244 -495.5647126\n",
      "f_favorite_route2                    -0.0329353755 0.002428530  -13.5618580\n",
      "f_favorite_route3                    -0.0055255705 0.003975518   -1.3898996\n",
      "f_favorite_route4                    -0.0470726450 0.002906425  -16.1960642\n",
      "f_favorite_route5                    -0.0507260638 0.002356474  -21.5262593\n",
      "f_favorite_route6                    -0.0230867494 0.003335433   -6.9216653\n",
      "f_favorite_route7                    -0.0513574862 0.003369780  -15.2406044\n",
      "f_favorite_route8                    -0.0082939643 0.002215576   -3.7434797\n",
      "f_favorite_route9                    -0.0056298933 0.002764836   -2.0362487\n",
      "f_favorite_route10                   -0.0339031018 0.002744827  -12.3516355\n",
      "f_favorite_route11                   -0.0047807558 0.003311048   -1.4438798\n",
      "f_favorite_route12                    0.0327156549 0.003447923    9.4885104\n",
      "f_favorite_route13                    0.0180883953 0.004569884    3.9581740\n",
      "f_favorite_route14                   -0.0225994553 0.002302079   -9.8169777\n",
      "f_favorite_route15                   -0.0370726139 0.002917381  -12.7074964\n",
      "f_favorite_route16                    0.0137950171 0.002916270    4.7303638\n",
      "f_favorite_route17                    0.0371640748 0.003327873   11.1675173\n",
      "f_favorite_route18                   -0.0445410382 0.002783115  -16.0040255\n",
      "f_favorite_route19                    0.0161122680 0.003315693    4.8593961\n",
      "f_favorite_route20                   -0.0269329051 0.002919292   -9.2258361\n",
      "f_favorite_route21                    0.0146016489 0.002983788    4.8936609\n",
      "imputed_new_buses:Is405North_10_ride -0.0281960849 0.003127913   -9.0143456\n",
      "                                          Pr(>|t|)\n",
      "(Intercept)                           0.000000e+00\n",
      "imputed_new_buses                     1.148964e-02\n",
      "fDate2015-09-03                       9.206701e-01\n",
      "fDate2015-09-04                       1.390495e-25\n",
      "fDate2015-09-08                       5.486493e-09\n",
      "fDate2015-09-09                       3.350355e-03\n",
      "fDate2015-09-10                       9.973574e-02\n",
      "fDate2015-09-11                       4.501215e-08\n",
      "fDate2015-09-14                       5.906298e-15\n",
      "fDate2015-09-15                       2.814397e-04\n",
      "fDate2015-09-16                       2.449928e-03\n",
      "fDate2015-09-17                       5.120911e-05\n",
      "fDate2015-09-18                       1.645069e-01\n",
      "fDate2015-09-21                       3.109766e-17\n",
      "fDate2015-09-22                       1.523961e-08\n",
      "fDate2015-09-23                       7.514942e-03\n",
      "fDate2015-09-24                       3.159753e-10\n",
      "fDate2015-09-25                       5.627013e-01\n",
      "fDate2015-09-28                       4.618291e-17\n",
      "fDate2015-09-29                       1.229141e-11\n",
      "fDate2015-09-30                       9.839629e-08\n",
      "fDate2015-10-01                       5.297564e-06\n",
      "fDate2015-10-02                       1.551905e-01\n",
      "fDate2015-10-05                       1.005566e-14\n",
      "fDate2015-10-06                       2.368465e-10\n",
      "fDate2015-10-07                       3.499017e-07\n",
      "fDate2015-10-08                       1.629673e-07\n",
      "fDate2015-10-09                       7.905115e-10\n",
      "fDate2015-10-12                       1.326235e-17\n",
      "fDate2015-10-13                       1.362286e-09\n",
      "fDate2015-10-14                       1.008484e-03\n",
      "fDate2015-10-15                       1.700756e-08\n",
      "fDate2015-10-16                       2.516643e-01\n",
      "fDate2015-10-19                       1.585135e-23\n",
      "fDate2015-10-20                       5.487622e-13\n",
      "fDate2015-10-21                       8.491471e-07\n",
      "fDate2015-10-22                       1.948068e-03\n",
      "fDate2015-10-23                       2.148110e-02\n",
      "fDate2015-10-26                       2.650219e-19\n",
      "fDate2015-10-27                       2.394516e-11\n",
      "fDate2015-10-28                       1.116745e-08\n",
      "fDate2015-10-29                       6.330554e-10\n",
      "fDate2015-10-30                       8.287722e-01\n",
      "fDate2015-11-02                       8.805369e-23\n",
      "fDate2015-11-03                       1.936846e-15\n",
      "fDate2015-11-04                       4.175675e-10\n",
      "fDate2015-11-05                       4.258309e-12\n",
      "fDate2015-11-06                       7.121849e-01\n",
      "fDate2015-11-09                       1.203745e-24\n",
      "fDate2015-11-10                       8.366212e-18\n",
      "fDate2015-11-11                       4.223758e-07\n",
      "fDate2015-11-12                       1.272954e-08\n",
      "fDate2015-11-13                       2.095020e-01\n",
      "fDate2015-11-16                       9.384498e-36\n",
      "fDate2015-11-17                       2.639411e-11\n",
      "fDate2015-11-18                       7.738606e-08\n",
      "fDate2015-11-19                       5.871400e-11\n",
      "fDate2015-11-20                       3.858539e-01\n",
      "fDate2015-11-23                       2.651117e-01\n",
      "fDate2015-11-24                       2.384087e-01\n",
      "fDate2015-11-25                       1.999588e-29\n",
      "fDate2015-11-30                       3.376293e-70\n",
      "fDate2015-12-01                       6.988989e-21\n",
      "fDate2015-12-02                       1.279139e-26\n",
      "fDate2015-12-03                       1.386802e-07\n",
      "fDate2015-12-04                       2.240439e-02\n",
      "fDate2015-12-07                       1.404734e-15\n",
      "fDate2015-12-08                       8.797799e-16\n",
      "fDate2015-12-09                       7.855588e-08\n",
      "fDate2015-12-10                       1.760970e-10\n",
      "fDate2015-12-11                       1.013647e-01\n",
      "fDate2015-12-14                       9.858991e-26\n",
      "fDate2015-12-15                       1.707823e-09\n",
      "fDate2015-12-16                       4.831308e-06\n",
      "fDate2015-12-17                       1.480674e-08\n",
      "fDate2015-12-18                       1.282599e-06\n",
      "fDate2016-01-04                      7.854812e-100\n",
      "fDate2016-01-05                       4.685121e-44\n",
      "fDate2016-01-06                       2.655928e-37\n",
      "fDate2016-01-07                       5.830461e-44\n",
      "fDate2016-01-08                       5.347639e-27\n",
      "fDate2016-01-11                       9.003433e-58\n",
      "fDate2016-01-12                       2.713927e-44\n",
      "fDate2016-01-13                       1.948374e-45\n",
      "fDate2016-01-14                       2.497462e-50\n",
      "fDate2016-01-15                       2.385275e-26\n",
      "fDate2016-01-19                       1.019204e-60\n",
      "fDate2016-01-20                       1.780558e-41\n",
      "fDate2016-01-21                       3.561172e-44\n",
      "fDate2016-01-22                       1.684926e-24\n",
      "fDate2016-01-25                       3.087233e-56\n",
      "fDate2016-01-26                       2.621957e-51\n",
      "fDate2016-01-27                       2.009997e-47\n",
      "fDate2016-01-28                       6.125483e-47\n",
      "fDate2016-01-29                       9.384437e-30\n",
      "fDate2016-02-01                       2.050834e-21\n",
      "fDate2016-02-02                       1.011902e-37\n",
      "fDate2016-02-03                       1.173144e-41\n",
      "fDate2016-02-04                       1.815998e-45\n",
      "fDate2016-02-05                       1.571442e-29\n",
      "fDate2016-02-08                       2.020675e-60\n",
      "fDate2016-02-09                       1.067508e-09\n",
      "fDate2016-02-10                       2.959090e-05\n",
      "fDate2016-02-11                       5.943484e-11\n",
      "fDate2016-02-12                       1.813972e-02\n",
      "fDate2016-02-16                       4.080982e-15\n",
      "fDate2016-02-17                       1.912083e-12\n",
      "fDate2016-02-18                       1.548479e-07\n",
      "fDate2016-02-19                       6.997431e-02\n",
      "fDate2016-02-22                       9.987319e-22\n",
      "fDate2016-02-23                       8.929015e-21\n",
      "fDate2016-02-24                       2.731463e-09\n",
      "fDate2016-02-25                       1.060069e-09\n",
      "fDate2016-02-26                       2.520628e-02\n",
      "fDate2016-02-29                       6.015655e-27\n",
      "fDate2016-03-01                       1.944183e-14\n",
      "fDate2016-03-02                       1.149497e-17\n",
      "fDate2016-03-03                       1.785143e-13\n",
      "fDate2016-03-04                       1.786131e-02\n",
      "fDate2016-03-07                       1.305612e-27\n",
      "fDate2016-03-08                       5.427672e-18\n",
      "fDate2016-03-09                       7.955306e-12\n",
      "fDate2016-03-10                       1.692648e-10\n",
      "fDate2016-03-11                       1.155349e-01\n",
      "fDate2016-03-14                       2.304325e-19\n",
      "fDate2016-03-15                       1.244976e-17\n",
      "fDate2016-03-16                       1.742731e-14\n",
      "fDate2016-03-17                       1.227532e-14\n",
      "fDate2016-03-18                       3.658010e-01\n",
      "fDate2016-03-21                       1.343552e-37\n",
      "fDate2016-03-22                       1.240458e-21\n",
      "fDate2016-03-23                       1.218286e-10\n",
      "fDate2016-03-24                       4.084069e-16\n",
      "fDate2016-03-25                       2.759936e-01\n",
      "fDate2016-03-28                       7.770992e-23\n",
      "fDate2016-03-29                       4.830654e-07\n",
      "fDate2016-03-30                       2.106549e-13\n",
      "fDate2016-03-31                       1.528309e-09\n",
      "fDate2016-04-01                       8.933071e-01\n",
      "fDate2016-04-04                       1.122187e-22\n",
      "fDate2016-04-05                       1.421165e-17\n",
      "fDate2016-04-06                       5.457892e-11\n",
      "fDate2016-04-07                       5.017729e-06\n",
      "fDate2016-04-08                       1.097164e-01\n",
      "f_commutes_since_last_ride2           0.000000e+00\n",
      "f_commutes_since_last_ride3           0.000000e+00\n",
      "f_commutes_since_last_ride4           0.000000e+00\n",
      "f_commutes_since_last_ride5           0.000000e+00\n",
      "f_commutes_since_last_ride6           0.000000e+00\n",
      "f_commutes_since_last_ride7           0.000000e+00\n",
      "f_commutes_since_last_ride8           0.000000e+00\n",
      "f_commutes_since_last_ride9           0.000000e+00\n",
      "f_commutes_since_last_ride10          0.000000e+00\n",
      "f_commutes_since_last_ride11          0.000000e+00\n",
      "f_commutes_since_last_ride12          0.000000e+00\n",
      "f_commutes_since_last_ride13          0.000000e+00\n",
      "f_commutes_since_last_ride14          0.000000e+00\n",
      "f_commutes_since_last_ride15          0.000000e+00\n",
      "f_commutes_since_last_ride16          0.000000e+00\n",
      "f_commutes_since_last_ride17          0.000000e+00\n",
      "f_commutes_since_last_ride18          0.000000e+00\n",
      "f_commutes_since_last_ride19          0.000000e+00\n",
      "f_commutes_since_last_ride20          0.000000e+00\n",
      "f_commutes_since_last_ride21          0.000000e+00\n",
      "f_commutes_since_last_ride22          0.000000e+00\n",
      "f_commutes_since_last_ride23          0.000000e+00\n",
      "f_commutes_since_last_ride24          0.000000e+00\n",
      "f_commutes_since_last_ride25          0.000000e+00\n",
      "f_commutes_since_last_ride26          0.000000e+00\n",
      "f_commutes_since_last_ride27          0.000000e+00\n",
      "f_commutes_since_last_ride28          0.000000e+00\n",
      "f_commutes_since_last_ride29          0.000000e+00\n",
      "f_commutes_since_last_ride30          0.000000e+00\n",
      "f_commutes_since_last_ride31          0.000000e+00\n",
      "f_commutes_since_last_ride32          0.000000e+00\n",
      "f_commutes_since_last_ride33          0.000000e+00\n",
      "f_commutes_since_last_ride34          0.000000e+00\n",
      "f_commutes_since_last_ride35          0.000000e+00\n",
      "f_commutes_since_last_ride36          0.000000e+00\n",
      "f_commutes_since_last_ride37          0.000000e+00\n",
      "f_commutes_since_last_ride38          0.000000e+00\n",
      "f_commutes_since_last_ride39          0.000000e+00\n",
      "f_commutes_since_last_ride40          0.000000e+00\n",
      "f_favorite_route2                     6.793057e-42\n",
      "f_favorite_route3                     1.645597e-01\n",
      "f_favorite_route4                     5.461002e-59\n",
      "f_favorite_route5                    9.280780e-103\n",
      "f_favorite_route6                     4.466065e-12\n",
      "f_favorite_route7                     1.924599e-52\n",
      "f_favorite_route8                     1.814984e-04\n",
      "f_favorite_route9                     4.172563e-02\n",
      "f_favorite_route10                    4.798661e-35\n",
      "f_favorite_route11                    1.487731e-01\n",
      "f_favorite_route12                    2.347992e-21\n",
      "f_favorite_route13                    7.552967e-05\n",
      "f_favorite_route14                    9.535799e-23\n",
      "f_favorite_route15                    5.404921e-37\n",
      "f_favorite_route16                    2.241455e-06\n",
      "f_favorite_route17                    5.901225e-29\n",
      "f_favorite_route18                    1.215800e-57\n",
      "f_favorite_route19                    1.177604e-06\n",
      "f_favorite_route20                    2.818298e-20\n",
      "f_favorite_route21                    9.899123e-07\n",
      "imputed_new_buses:Is405North_10_ride  1.983529e-19\n",
      "\n",
      "=------------------------======================\n",
      "Missing coefficients:\n",
      " Is405North_10_ride:I405HOV imputed_new_buses:I405HOV imputed_new_buses:Is405North_10_ride:I405HOV\n",
      "\n",
      "Available coefficients:\n",
      "  [1] \"(Intercept)\"                         \n",
      "  [2] \"imputed_new_buses\"                   \n",
      "  [3] \"fDate2015-09-03\"                     \n",
      "  [4] \"fDate2015-09-04\"                     \n",
      "  [5] \"fDate2015-09-08\"                     \n",
      "  [6] \"fDate2015-09-09\"                     \n",
      "  [7] \"fDate2015-09-10\"                     \n",
      "  [8] \"fDate2015-09-11\"                     \n",
      "  [9] \"fDate2015-09-14\"                     \n",
      " [10] \"fDate2015-09-15\"                     \n",
      " [11] \"fDate2015-09-16\"                     \n",
      " [12] \"fDate2015-09-17\"                     \n",
      " [13] \"fDate2015-09-18\"                     \n",
      " [14] \"fDate2015-09-21\"                     \n",
      " [15] \"fDate2015-09-22\"                     \n",
      " [16] \"fDate2015-09-23\"                     \n",
      " [17] \"fDate2015-09-24\"                     \n",
      " [18] \"fDate2015-09-25\"                     \n",
      " [19] \"fDate2015-09-28\"                     \n",
      " [20] \"fDate2015-09-29\"                     \n",
      " [21] \"fDate2015-09-30\"                     \n",
      " [22] \"fDate2015-10-01\"                     \n",
      " [23] \"fDate2015-10-02\"                     \n",
      " [24] \"fDate2015-10-05\"                     \n",
      " [25] \"fDate2015-10-06\"                     \n",
      " [26] \"fDate2015-10-07\"                     \n",
      " [27] \"fDate2015-10-08\"                     \n",
      " [28] \"fDate2015-10-09\"                     \n",
      " [29] \"fDate2015-10-12\"                     \n",
      " [30] \"fDate2015-10-13\"                     \n",
      " [31] \"fDate2015-10-14\"                     \n",
      " [32] \"fDate2015-10-15\"                     \n",
      " [33] \"fDate2015-10-16\"                     \n",
      " [34] \"fDate2015-10-19\"                     \n",
      " [35] \"fDate2015-10-20\"                     \n",
      " [36] \"fDate2015-10-21\"                     \n",
      " [37] \"fDate2015-10-22\"                     \n",
      " [38] \"fDate2015-10-23\"                     \n",
      " [39] \"fDate2015-10-26\"                     \n",
      " [40] \"fDate2015-10-27\"                     \n",
      " [41] \"fDate2015-10-28\"                     \n",
      " [42] \"fDate2015-10-29\"                     \n",
      " [43] \"fDate2015-10-30\"                     \n",
      " [44] \"fDate2015-11-02\"                     \n",
      " [45] \"fDate2015-11-03\"                     \n",
      " [46] \"fDate2015-11-04\"                     \n",
      " [47] \"fDate2015-11-05\"                     \n",
      " [48] \"fDate2015-11-06\"                     \n",
      " [49] \"fDate2015-11-09\"                     \n",
      " [50] \"fDate2015-11-10\"                     \n",
      " [51] \"fDate2015-11-11\"                     \n",
      " [52] \"fDate2015-11-12\"                     \n",
      " [53] \"fDate2015-11-13\"                     \n",
      " [54] \"fDate2015-11-16\"                     \n",
      " [55] \"fDate2015-11-17\"                     \n",
      " [56] \"fDate2015-11-18\"                     \n",
      " [57] \"fDate2015-11-19\"                     \n",
      " [58] \"fDate2015-11-20\"                     \n",
      " [59] \"fDate2015-11-23\"                     \n",
      " [60] \"fDate2015-11-24\"                     \n",
      " [61] \"fDate2015-11-25\"                     \n",
      " [62] \"fDate2015-11-30\"                     \n",
      " [63] \"fDate2015-12-01\"                     \n",
      " [64] \"fDate2015-12-02\"                     \n",
      " [65] \"fDate2015-12-03\"                     \n",
      " [66] \"fDate2015-12-04\"                     \n",
      " [67] \"fDate2015-12-07\"                     \n",
      " [68] \"fDate2015-12-08\"                     \n",
      " [69] \"fDate2015-12-09\"                     \n",
      " [70] \"fDate2015-12-10\"                     \n",
      " [71] \"fDate2015-12-11\"                     \n",
      " [72] \"fDate2015-12-14\"                     \n",
      " [73] \"fDate2015-12-15\"                     \n",
      " [74] \"fDate2015-12-16\"                     \n",
      " [75] \"fDate2015-12-17\"                     \n",
      " [76] \"fDate2015-12-18\"                     \n",
      " [77] \"fDate2016-01-04\"                     \n",
      " [78] \"fDate2016-01-05\"                     \n",
      " [79] \"fDate2016-01-06\"                     \n",
      " [80] \"fDate2016-01-07\"                     \n",
      " [81] \"fDate2016-01-08\"                     \n",
      " [82] \"fDate2016-01-11\"                     \n",
      " [83] \"fDate2016-01-12\"                     \n",
      " [84] \"fDate2016-01-13\"                     \n",
      " [85] \"fDate2016-01-14\"                     \n",
      " [86] \"fDate2016-01-15\"                     \n",
      " [87] \"fDate2016-01-19\"                     \n",
      " [88] \"fDate2016-01-20\"                     \n",
      " [89] \"fDate2016-01-21\"                     \n",
      " [90] \"fDate2016-01-22\"                     \n",
      " [91] \"fDate2016-01-25\"                     \n",
      " [92] \"fDate2016-01-26\"                     \n",
      " [93] \"fDate2016-01-27\"                     \n",
      " [94] \"fDate2016-01-28\"                     \n",
      " [95] \"fDate2016-01-29\"                     \n",
      " [96] \"fDate2016-02-01\"                     \n",
      " [97] \"fDate2016-02-02\"                     \n",
      " [98] \"fDate2016-02-03\"                     \n",
      " [99] \"fDate2016-02-04\"                     \n",
      "[100] \"fDate2016-02-05\"                     \n",
      "[101] \"fDate2016-02-08\"                     \n",
      "[102] \"fDate2016-02-09\"                     \n",
      "[103] \"fDate2016-02-10\"                     \n",
      "[104] \"fDate2016-02-11\"                     \n",
      "[105] \"fDate2016-02-12\"                     \n",
      "[106] \"fDate2016-02-16\"                     \n",
      "[107] \"fDate2016-02-17\"                     \n",
      "[108] \"fDate2016-02-18\"                     \n",
      "[109] \"fDate2016-02-19\"                     \n",
      "[110] \"fDate2016-02-22\"                     \n",
      "[111] \"fDate2016-02-23\"                     \n",
      "[112] \"fDate2016-02-24\"                     \n",
      "[113] \"fDate2016-02-25\"                     \n",
      "[114] \"fDate2016-02-26\"                     \n",
      "[115] \"fDate2016-02-29\"                     \n",
      "[116] \"fDate2016-03-01\"                     \n",
      "[117] \"fDate2016-03-02\"                     \n",
      "[118] \"fDate2016-03-03\"                     \n",
      "[119] \"fDate2016-03-04\"                     \n",
      "[120] \"fDate2016-03-07\"                     \n",
      "[121] \"fDate2016-03-08\"                     \n",
      "[122] \"fDate2016-03-09\"                     \n",
      "[123] \"fDate2016-03-10\"                     \n",
      "[124] \"fDate2016-03-11\"                     \n",
      "[125] \"fDate2016-03-14\"                     \n",
      "[126] \"fDate2016-03-15\"                     \n",
      "[127] \"fDate2016-03-16\"                     \n",
      "[128] \"fDate2016-03-17\"                     \n",
      "[129] \"fDate2016-03-18\"                     \n",
      "[130] \"fDate2016-03-21\"                     \n",
      "[131] \"fDate2016-03-22\"                     \n",
      "[132] \"fDate2016-03-23\"                     \n",
      "[133] \"fDate2016-03-24\"                     \n",
      "[134] \"fDate2016-03-25\"                     \n",
      "[135] \"fDate2016-03-28\"                     \n",
      "[136] \"fDate2016-03-29\"                     \n",
      "[137] \"fDate2016-03-30\"                     \n",
      "[138] \"fDate2016-03-31\"                     \n",
      "[139] \"fDate2016-04-01\"                     \n",
      "[140] \"fDate2016-04-04\"                     \n",
      "[141] \"fDate2016-04-05\"                     \n",
      "[142] \"fDate2016-04-06\"                     \n",
      "[143] \"fDate2016-04-07\"                     \n",
      "[144] \"fDate2016-04-08\"                     \n",
      "[145] \"f_commutes_since_last_ride2\"         \n",
      "[146] \"f_commutes_since_last_ride3\"         \n",
      "[147] \"f_commutes_since_last_ride4\"         \n",
      "[148] \"f_commutes_since_last_ride5\"         \n",
      "[149] \"f_commutes_since_last_ride6\"         \n",
      "[150] \"f_commutes_since_last_ride7\"         \n",
      "[151] \"f_commutes_since_last_ride8\"         \n",
      "[152] \"f_commutes_since_last_ride9\"         \n",
      "[153] \"f_commutes_since_last_ride10\"        \n",
      "[154] \"f_commutes_since_last_ride11\"        \n",
      "[155] \"f_commutes_since_last_ride12\"        \n",
      "[156] \"f_commutes_since_last_ride13\"        \n",
      "[157] \"f_commutes_since_last_ride14\"        \n",
      "[158] \"f_commutes_since_last_ride15\"        \n",
      "[159] \"f_commutes_since_last_ride16\"        \n",
      "[160] \"f_commutes_since_last_ride17\"        \n",
      "[161] \"f_commutes_since_last_ride18\"        \n",
      "[162] \"f_commutes_since_last_ride19\"        \n",
      "[163] \"f_commutes_since_last_ride20\"        \n",
      "[164] \"f_commutes_since_last_ride21\"        \n",
      "[165] \"f_commutes_since_last_ride22\"        \n",
      "[166] \"f_commutes_since_last_ride23\"        \n",
      "[167] \"f_commutes_since_last_ride24\"        \n",
      "[168] \"f_commutes_since_last_ride25\"        \n",
      "[169] \"f_commutes_since_last_ride26\"        \n",
      "[170] \"f_commutes_since_last_ride27\"        \n",
      "[171] \"f_commutes_since_last_ride28\"        \n",
      "[172] \"f_commutes_since_last_ride29\"        \n",
      "[173] \"f_commutes_since_last_ride30\"        \n",
      "[174] \"f_commutes_since_last_ride31\"        \n",
      "[175] \"f_commutes_since_last_ride32\"        \n",
      "[176] \"f_commutes_since_last_ride33\"        \n",
      "[177] \"f_commutes_since_last_ride34\"        \n",
      "[178] \"f_commutes_since_last_ride35\"        \n",
      "[179] \"f_commutes_since_last_ride36\"        \n",
      "[180] \"f_commutes_since_last_ride37\"        \n",
      "[181] \"f_commutes_since_last_ride38\"        \n",
      "[182] \"f_commutes_since_last_ride39\"        \n",
      "[183] \"f_commutes_since_last_ride40\"        \n",
      "[184] \"f_favorite_route2\"                   \n",
      "[185] \"f_favorite_route3\"                   \n",
      "[186] \"f_favorite_route4\"                   \n",
      "[187] \"f_favorite_route5\"                   \n",
      "[188] \"f_favorite_route6\"                   \n",
      "[189] \"f_favorite_route7\"                   \n",
      "[190] \"f_favorite_route8\"                   \n",
      "[191] \"f_favorite_route9\"                   \n",
      "[192] \"f_favorite_route10\"                  \n",
      "[193] \"f_favorite_route11\"                  \n",
      "[194] \"f_favorite_route12\"                  \n",
      "[195] \"f_favorite_route13\"                  \n",
      "[196] \"f_favorite_route14\"                  \n",
      "[197] \"f_favorite_route15\"                  \n",
      "[198] \"f_favorite_route16\"                  \n",
      "[199] \"f_favorite_route17\"                  \n",
      "[200] \"f_favorite_route18\"                  \n",
      "[201] \"f_favorite_route19\"                  \n",
      "[202] \"f_favorite_route20\"                  \n",
      "[203] \"f_favorite_route21\"                  \n",
      "[204] \"imputed_new_buses:Is405North_10_ride\"\n"
     ]
    },
    {
     "ename": "ERROR",
     "evalue": "Error in coef(summary(LM))[predictors, ]: subscript out of bounds\n",
     "output_type": "error",
     "traceback": [
      "Error in coef(summary(LM))[predictors, ]: subscript out of bounds\nTraceback:\n",
      "1. fit_ridership_logit_models(data = commute_ride_data[(!SR520WBHOV) & \n .     (!SR520EBHOV)], predictors = c(\"imputed_new_buses\", \"Is405North_10_ride:I405HOV\", \n .     \"imputed_new_buses:I405HOV\", \"imputed_new_buses:Is405North_10_ride\", \n .     \"imputed_new_buses:Is405North_10_ride:I405HOV\"), adjust_for = c(\"imputed_new_buses + fDate\", \n .     \"f_commutes_since_last_ride\", \"f_favorite_route\"), model = 3, \n .     granularity = \"rider/date/commute\")",
      "2. tryCatch({\n .     print(coef(summary(LM))[predictors, ])\n . }, error = function(err) {\n .     model_coef = dimnames(coef(summary(LM)))[[1]]\n .     cat(\"\\n=------------------------======================\\n\")\n .     print(FMLA)\n .     print(coef(summary(LM)))\n .     cat(\"\\n=------------------------======================\\n\")\n .     cat(\"Missing coefficients:\\n\", predictors[!predictors %in% \n .         model_coef])\n .     cat(\"\\n\\nAvailable coefficients:\\n\")\n .     print(model_coef)\n .     stop(err)\n . })   # at line 74-88 of file <text>",
      "3. tryCatchList(expr, classes, parentenv, handlers)",
      "4. tryCatchOne(expr, names, parentenv, handlers[[1L]])",
      "5. value[[3L]](cond)"
     ]
    }
   ],
   "source": [
    "(T4_M3 = fit_ridership_logit_models(data = commute_ride_data[(!SR520WBHOV) &  (!SR520EBHOV)],\n",
    "                            predictors=c(\n",
    "                                        \"imputed_new_buses\",\n",
    "                                        \"Is405North_10_ride:I405HOV\",\n",
    "                                        \"imputed_new_buses:I405HOV\",\n",
    "                                        \"imputed_new_buses:Is405North_10_ride\",\n",
    "                                        \"imputed_new_buses:Is405North_10_ride:I405HOV\"\n",
    "                                        ),\n",
    "                            adjust_for=c(\"imputed_new_buses + fDate\",\n",
    "                                            \"f_commutes_since_last_ride\",\n",
    "                                            \"f_favorite_route\"),\n",
    "                            model=3,\n",
    "                            granularity=\"rider/date/commute\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "===============================================\n",
      "Model  4 :\n",
      "===============================================\n",
      "\n",
      "\n",
      "Coefficients from Linear model (adjust_for effects omitted):\n",
      "\n",
      "=------------------------======================\n",
      "did_ride ~ imputed_new_buses + imputed_new_buses:single_stop_10_ride + \n",
      "    Is405North_10_ride:I405HOV + imputed_new_buses:Is405North_10_ride:I405HOV + \n",
      "    single_stop_10_ride:Is405North_10_ride:I405HOV + imputed_new_buses + \n",
      "    fDate + f_commutes_since_last_ride + f_favorite_route\n",
      "<environment: 0x0000000005a51b18>\n",
      "                                           Estimate  Std. Error      t value\n",
      "(Intercept)                            0.6373017033 0.006471169   98.4832356\n",
      "imputed_new_buses                     -0.0142060705 0.001969738   -7.2121619\n",
      "fDate2015-09-03                       -0.0009456352 0.008352556   -0.1132151\n",
      "fDate2015-09-04                       -0.0858022462 0.008195695  -10.4691844\n",
      "fDate2015-09-08                        0.0472489144 0.008132681    5.8097585\n",
      "fDate2015-09-09                        0.0234397428 0.008030059    2.9189999\n",
      "fDate2015-09-10                        0.0130271030 0.007965645    1.6354109\n",
      "fDate2015-09-11                       -0.0434743974 0.007929331   -5.4827323\n",
      "fDate2015-09-14                        0.0615865000 0.007902941    7.7928588\n",
      "fDate2015-09-15                        0.0284741502 0.007865536    3.6201158\n",
      "fDate2015-09-16                        0.0236836058 0.007848282    3.0176804\n",
      "fDate2015-09-17                        0.0315729199 0.007833596    4.0304504\n",
      "fDate2015-09-18                       -0.0110075247 0.007821821   -1.4072841\n",
      "fDate2015-09-21                        0.0658054028 0.007812160    8.4234583\n",
      "fDate2015-09-22                        0.0440096455 0.007803978    5.6393860\n",
      "fDate2015-09-23                       -0.0210469951 0.007798165   -2.6989677\n",
      "fDate2015-09-24                        0.0489019003 0.007799348    6.2699984\n",
      "fDate2015-09-25                       -0.0046684514 0.007799213   -0.5985798\n",
      "fDate2015-09-28                        0.0653005944 0.007799074    8.3728649\n",
      "fDate2015-09-29                        0.0527028786 0.007797203    6.7592031\n",
      "fDate2015-09-30                        0.0414686437 0.007797760    5.3180201\n",
      "fDate2015-10-01                        0.0354584085 0.007797923    4.5471604\n",
      "fDate2015-10-02                       -0.0111157108 0.007799495   -1.4251834\n",
      "fDate2015-10-05                        0.0603753793 0.007800872    7.7395682\n",
      "fDate2015-10-06                        0.0493840296 0.007797898    6.3329925\n",
      "fDate2015-10-07                        0.0397254547 0.007798285    5.0941273\n",
      "fDate2015-10-08                        0.0407847173 0.007798514    5.2298066\n",
      "fDate2015-10-09                       -0.0478577917 0.007803010   -6.1332476\n",
      "fDate2015-10-12                        0.0667256609 0.007800738    8.5537621\n",
      "fDate2015-10-13                        0.0474503474 0.007798883    6.0842492\n",
      "fDate2015-10-14                        0.0259249823 0.007800374    3.3235561\n",
      "fDate2015-10-15                        0.0443724316 0.007800604    5.6883329\n",
      "fDate2015-10-16                       -0.0084853237 0.007802177   -1.0875584\n",
      "fDate2015-10-19                        0.0786084971 0.007802790   10.0744094\n",
      "fDate2015-10-20                        0.0570361676 0.007801207    7.3111975\n",
      "fDate2015-10-21                        0.0393225578 0.007803566    5.0390499\n",
      "fDate2015-10-22                        0.0251816744 0.007805984    3.2259449\n",
      "fDate2015-10-23                       -0.0168955803 0.007810230   -2.1632629\n",
      "fDate2015-10-26                        0.0713223283 0.007812505    9.1292519\n",
      "fDate2015-10-27                        0.0533229120 0.007811370    6.8263197\n",
      "fDate2015-10-28                        0.0457928341 0.007813975    5.8603766\n",
      "fDate2015-10-29                        0.0494645252 0.007816244    6.3284262\n",
      "fDate2015-10-30                        0.0028543098 0.007819024    0.3650468\n",
      "fDate2015-11-02                        0.0779744258 0.007821630    9.9690763\n",
      "fDate2015-11-03                        0.0632117812 0.007820271    8.0830679\n",
      "fDate2015-11-04                        0.0498879837 0.007821660    6.3781837\n",
      "fDate2015-11-05                        0.0550964799 0.007824572    7.0414693\n",
      "fDate2015-11-06                       -0.0021571222 0.007828549   -0.2755456\n",
      "fDate2015-11-09                        0.0807701992 0.007829936   10.3155629\n",
      "fDate2015-11-10                        0.0676661843 0.007830419    8.6414511\n",
      "fDate2015-11-11                        0.0398299394 0.007833118    5.0848127\n",
      "fDate2015-11-12                        0.0446646715 0.007836155    5.6998195\n",
      "fDate2015-11-13                        0.0097982868 0.007840060    1.2497719\n",
      "fDate2015-11-16                        0.0977474825 0.007842227   12.4642503\n",
      "fDate2015-11-17                        0.0520456318 0.007842411    6.6364325\n",
      "fDate2015-11-18                        0.0418832272 0.007846452    5.3378555\n",
      "fDate2015-11-19                        0.0512172982 0.007848690    6.5255858\n",
      "fDate2015-11-20                        0.0066748818 0.007850581    0.8502405\n",
      "fDate2015-11-23                       -0.0088817482 0.007855138   -1.1306929\n",
      "fDate2015-11-24                       -0.0093552424 0.007857603   -1.1905975\n",
      "fDate2015-11-25                       -0.0885440458 0.007862536  -11.2615118\n",
      "fDate2015-11-30                        0.1392753319 0.007860154   17.7191607\n",
      "fDate2015-12-01                        0.0736753424 0.007853728    9.3809384\n",
      "fDate2015-12-02                        0.0839026632 0.007851830   10.6857459\n",
      "fDate2015-12-03                        0.0414188815 0.007853416    5.2739955\n",
      "fDate2015-12-04                        0.0179960668 0.007855667    2.2908387\n",
      "fDate2015-12-07                        0.0627185657 0.007854589    7.9849586\n",
      "fDate2015-12-08                        0.0631866950 0.007853703    8.0454657\n",
      "fDate2015-12-09                        0.0422116285 0.007854159    5.3744304\n",
      "fDate2015-12-10                        0.0501278816 0.007854971    6.3816764\n",
      "fDate2015-12-11                        0.0128457031 0.007855793    1.6351886\n",
      "fDate2015-12-14                        0.0823761479 0.007856069   10.4856708\n",
      "fDate2015-12-15                        0.0472759916 0.007854156    6.0192325\n",
      "fDate2015-12-16                        0.0358990964 0.007855529    4.5699148\n",
      "fDate2015-12-17                        0.0444687352 0.007856510    5.6601134\n",
      "fDate2015-12-18                       -0.0380797674 0.007859150   -4.8452778\n",
      "fDate2016-01-04                        0.1666267557 0.007856772   21.2080429\n",
      "fDate2016-01-05                        0.1092831980 0.007851777   13.9182752\n",
      "fDate2016-01-06                        0.1001632374 0.007851576   12.7570862\n",
      "fDate2016-01-07                        0.1091598584 0.007851895   13.9023584\n",
      "fDate2016-01-08                        0.0844395141 0.007852584   10.7530868\n",
      "fDate2016-01-11                        0.1257698211 0.007852752   16.0160183\n",
      "fDate2016-01-12                        0.1095543718 0.007851711   13.9529293\n",
      "fDate2016-01-13                        0.1110093597 0.007851712   14.1382357\n",
      "fDate2016-01-14                        0.1170834630 0.007852066   14.9111663\n",
      "fDate2016-01-15                        0.0833908098 0.007854867   10.6164503\n",
      "fDate2016-01-19                        0.1290175294 0.007852541   16.4300359\n",
      "fDate2016-01-20                        0.1058494573 0.007851919   13.4807123\n",
      "fDate2016-01-21                        0.1094542479 0.007854317   13.9355534\n",
      "fDate2016-01-22                        0.0801419627 0.007852421   10.2060197\n",
      "fDate2016-01-25                        0.1240134628 0.007853175   15.7915069\n",
      "fDate2016-01-26                        0.1182504130 0.007852154   15.0596139\n",
      "fDate2016-01-27                        0.1135320983 0.007851986   14.4590289\n",
      "fDate2016-01-28                        0.1129359074 0.007852226   14.3826607\n",
      "fDate2016-01-29                        0.0889143480 0.007852461   11.3231181\n",
      "fDate2016-02-01                        0.0746062234 0.007854035    9.4990952\n",
      "fDate2016-02-02                        0.1008029746 0.007853834   12.8348740\n",
      "fDate2016-02-03                        0.1061410051 0.007851973   13.5177491\n",
      "fDate2016-02-04                        0.1110964719 0.007851950   14.1489014\n",
      "fDate2016-02-05                        0.0886140363 0.007852351   11.2850319\n",
      "fDate2016-02-08                        0.1287487983 0.007852099   16.3967370\n",
      "fDate2016-02-09                        0.0479124847 0.007852185    6.1018032\n",
      "fDate2016-02-10                        0.0328046602 0.007855655    4.1759296\n",
      "fDate2016-02-11                        0.0514100947 0.007856116    6.5439585\n",
      "fDate2016-02-12                       -0.0185929954 0.007857270   -2.3663429\n",
      "fDate2016-02-16                        0.0616564610 0.007858679    7.8456524\n",
      "fDate2016-02-17                        0.0552588475 0.007856367    7.0336389\n",
      "fDate2016-02-18                        0.0411590914 0.007856685    5.2387354\n",
      "fDate2016-02-19                        0.0141673013 0.007857898    1.8029377\n",
      "fDate2016-02-22                        0.0751518442 0.007857943    9.5638068\n",
      "fDate2016-02-23                        0.0733030344 0.007855274    9.3316964\n",
      "fDate2016-02-24                        0.0465521474 0.007855128    5.9263386\n",
      "fDate2016-02-25                        0.0477744288 0.007856126    6.0811688\n",
      "fDate2016-02-26                        0.0174526449 0.007856967    2.2212955\n",
      "fDate2016-02-29                        0.0843317851 0.007857605   10.7325049\n",
      "fDate2016-03-01                        0.0599894792 0.007854960    7.6371460\n",
      "fDate2016-03-02                        0.0670999170 0.007855495    8.5417811\n",
      "fDate2016-03-03                        0.0577216403 0.007855523    7.3479056\n",
      "fDate2016-03-04                        0.0184898774 0.007857026    2.3532920\n",
      "fDate2016-03-07                        0.0854285809 0.007857263   10.8725616\n",
      "fDate2016-03-08                        0.0677717536 0.007855672    8.6271106\n",
      "fDate2016-03-09                        0.0536135470 0.007856473    6.8241238\n",
      "fDate2016-03-10                        0.0500487002 0.007856922    6.3700138\n",
      "fDate2016-03-11                        0.0122375500 0.007858105    1.5573158\n",
      "fDate2016-03-14                        0.0705622869 0.007858545    8.9790520\n",
      "fDate2016-03-15                        0.0670278477 0.007857076    8.5308896\n",
      "fDate2016-03-16                        0.0601260385 0.007857166    7.6523827\n",
      "fDate2016-03-17                        0.0604750341 0.007857511    7.6964617\n",
      "fDate2016-03-18                        0.0070089413 0.007858246    0.8919219\n",
      "fDate2016-03-21                        0.1006890989 0.007858644   12.8125276\n",
      "fDate2016-03-22                        0.0750809843 0.007856633    9.5563822\n",
      "fDate2016-03-23                        0.0506055621 0.007857576    6.4403530\n",
      "fDate2016-03-24                        0.0639848412 0.007858842    8.1417647\n",
      "fDate2016-03-25                        0.0086432543 0.007860187    1.0996245\n",
      "fDate2016-03-28                        0.0774621779 0.007861713    9.8530911\n",
      "fDate2016-03-29                        0.0396869554 0.007860452    5.0489408\n",
      "fDate2016-03-30                        0.0578424698 0.007860851    7.3582964\n",
      "fDate2016-03-31                        0.0476534170 0.007861462    6.0616485\n",
      "fDate2016-04-01                        0.0011998838 0.007863871    0.1525818\n",
      "fDate2016-04-04                        0.0771803519 0.007864578    9.8136674\n",
      "fDate2016-04-05                        0.0671904393 0.007861960    8.5462708\n",
      "fDate2016-04-06                        0.0516637403 0.007861987    6.5713339\n",
      "fDate2016-04-07                        0.0360016679 0.007862773    4.5787494\n",
      "fDate2016-04-08                       -0.0124486525 0.007865121   -1.5827668\n",
      "f_commutes_since_last_ride2           -0.1970490418 0.001260772 -156.2923830\n",
      "f_commutes_since_last_ride3           -0.3242735860 0.001609546 -201.4689720\n",
      "f_commutes_since_last_ride4           -0.3669308623 0.001920097 -191.1002023\n",
      "f_commutes_since_last_ride5           -0.4312058780 0.002241213 -192.3984580\n",
      "f_commutes_since_last_ride6           -0.4471431145 0.002523184 -177.2138564\n",
      "f_commutes_since_last_ride7           -0.4905217097 0.002819846 -173.9533555\n",
      "f_commutes_since_last_ride8           -0.4887699944 0.003075489 -158.9243081\n",
      "f_commutes_since_last_ride9           -0.5163623097 0.003361338 -153.6180731\n",
      "f_commutes_since_last_ride10          -0.4710505516 0.003618949 -130.1622343\n",
      "f_commutes_since_last_ride11          -0.5549537136 0.004006777 -138.5037725\n",
      "f_commutes_since_last_ride12          -0.5548251952 0.004226224 -131.2815320\n",
      "f_commutes_since_last_ride13          -0.5659499463 0.004462895 -126.8122847\n",
      "f_commutes_since_last_ride14          -0.5614117792 0.004686685 -119.7886635\n",
      "f_commutes_since_last_ride15          -0.5742657465 0.004937110 -116.3161773\n",
      "f_commutes_since_last_ride16          -0.5749785866 0.005161102 -111.4061584\n",
      "f_commutes_since_last_ride17          -0.5801121351 0.005389285 -107.6417705\n",
      "f_commutes_since_last_ride18          -0.5833243828 0.005612370 -103.9354738\n",
      "f_commutes_since_last_ride19          -0.5860035385 0.005848227 -100.2019153\n",
      "f_commutes_since_last_ride20          -0.5707847739 0.006079422  -93.8880021\n",
      "f_commutes_since_last_ride21          -0.6119580873 0.006378861  -95.9353231\n",
      "f_commutes_since_last_ride22          -0.6046809280 0.006542834  -92.4188099\n",
      "f_commutes_since_last_ride23          -0.6092301875 0.006737309  -90.4263382\n",
      "f_commutes_since_last_ride24          -0.6037147858 0.006919304  -87.2508027\n",
      "f_commutes_since_last_ride25          -0.6177847558 0.007131087  -86.6326167\n",
      "f_commutes_since_last_ride26          -0.6097163584 0.007298462  -83.5403942\n",
      "f_commutes_since_last_ride27          -0.6096118616 0.007492252  -81.3656430\n",
      "f_commutes_since_last_ride28          -0.6169458059 0.007689906  -80.2279999\n",
      "f_commutes_since_last_ride29          -0.6255824980 0.007885129  -79.3370038\n",
      "f_commutes_since_last_ride30          -0.6129820550 0.008037482  -76.2654348\n",
      "f_commutes_since_last_ride31          -0.6343504888 0.008245205  -76.9356831\n",
      "f_commutes_since_last_ride32          -0.6298046661 0.008355017  -75.3804198\n",
      "f_commutes_since_last_ride33          -0.6340349024 0.008497086  -74.6179180\n",
      "f_commutes_since_last_ride34          -0.6326778276 0.008624873  -73.3550300\n",
      "f_commutes_since_last_ride35          -0.6402574982 0.008752206  -73.1538429\n",
      "f_commutes_since_last_ride36          -0.6370576526 0.008843480  -72.0369853\n",
      "f_commutes_since_last_ride37          -0.6405956817 0.008970474  -71.4115784\n",
      "f_commutes_since_last_ride38          -0.6305332377 0.009086112  -69.3952759\n",
      "f_commutes_since_last_ride39          -0.6416562788 0.009253806  -69.3397164\n",
      "f_commutes_since_last_ride40          -0.6558701312 0.001323711 -495.4781899\n",
      "f_favorite_route2                     -0.0388305783 0.002387910  -16.2613232\n",
      "f_favorite_route3                     -0.0292362782 0.003536962   -8.2659294\n",
      "f_favorite_route4                     -0.0520357560 0.003079993  -16.8947643\n",
      "f_favorite_route5                     -0.0564799901 0.002316546  -24.3811179\n",
      "f_favorite_route6                     -0.0235131157 0.003335379   -7.0496083\n",
      "f_favorite_route7                     -0.0572882465 0.003344349  -17.1298658\n",
      "f_favorite_route8                     -0.0078525774 0.002215367   -3.5445943\n",
      "f_favorite_route9                     -0.0115502808 0.002728848   -4.2326586\n",
      "f_favorite_route10                    -0.0349126154 0.002743867  -12.7238720\n",
      "f_favorite_route11                    -0.0041608829 0.003310855   -1.2567396\n",
      "f_favorite_route12                     0.0096989888 0.002853136    3.3994135\n",
      "f_favorite_route13                     0.0126820286 0.004594383    2.7603332\n",
      "f_favorite_route14                    -0.0217942480 0.002301397   -9.4700077\n",
      "f_favorite_route15                    -0.0430446212 0.002882421  -14.9334942\n",
      "f_favorite_route16                     0.0128369234 0.002915474    4.4030318\n",
      "f_favorite_route17                     0.0171568984 0.002519168    6.8105427\n",
      "f_favorite_route18                    -0.0478033899 0.003198525  -14.9454460\n",
      "f_favorite_route19                    -0.0036245478 0.002530877   -1.4321313\n",
      "f_favorite_route20                    -0.0318694787 0.002895817  -11.0053482\n",
      "f_favorite_route21                     0.0157396410 0.002982694    5.2769885\n",
      "imputed_new_buses:single_stop_10_ride  0.0105260771 0.004478290    2.3504680\n",
      "                                           Pr(>|t|)\n",
      "(Intercept)                            0.000000e+00\n",
      "imputed_new_buses                      5.510546e-13\n",
      "fDate2015-09-03                        9.098601e-01\n",
      "fDate2015-09-04                        1.200014e-25\n",
      "fDate2015-09-08                        6.258012e-09\n",
      "fDate2015-09-09                        3.511634e-03\n",
      "fDate2015-09-10                        1.019632e-01\n",
      "fDate2015-09-11                        4.188978e-08\n",
      "fDate2015-09-14                        6.556633e-15\n",
      "fDate2015-09-15                        2.944844e-04\n",
      "fDate2015-09-16                        2.547232e-03\n",
      "fDate2015-09-17                        5.567381e-05\n",
      "fDate2015-09-18                        1.593434e-01\n",
      "fDate2015-09-21                        3.659599e-17\n",
      "fDate2015-09-22                        1.706991e-08\n",
      "fDate2015-09-23                        6.955598e-03\n",
      "fDate2015-09-24                        3.611846e-10\n",
      "fDate2015-09-25                        5.494532e-01\n",
      "fDate2015-09-28                        5.629847e-17\n",
      "fDate2015-09-29                        1.388212e-11\n",
      "fDate2015-09-30                        1.049228e-07\n",
      "fDate2015-10-01                        5.438032e-06\n",
      "fDate2015-10-02                        1.541045e-01\n",
      "fDate2015-10-05                        9.983881e-15\n",
      "fDate2015-10-06                        2.405432e-10\n",
      "fDate2015-10-07                        3.504088e-07\n",
      "fDate2015-10-08                        1.697183e-07\n",
      "fDate2015-10-09                        8.613200e-10\n",
      "fDate2015-10-12                        1.192887e-17\n",
      "fDate2015-10-13                        1.170767e-09\n",
      "fDate2015-10-14                        8.888043e-04\n",
      "fDate2015-10-15                        1.283178e-08\n",
      "fDate2015-10-16                        2.767903e-01\n",
      "fDate2015-10-19                        7.186088e-24\n",
      "fDate2015-10-20                        2.649497e-13\n",
      "fDate2015-10-21                        4.679222e-07\n",
      "fDate2015-10-22                        1.255612e-03\n",
      "fDate2015-10-23                        3.052118e-02\n",
      "fDate2015-10-26                        6.908544e-20\n",
      "fDate2015-10-27                        8.716533e-12\n",
      "fDate2015-10-28                        4.619490e-09\n",
      "fDate2015-10-29                        2.477687e-10\n",
      "fDate2015-10-30                        7.150765e-01\n",
      "fDate2015-11-02                        2.086309e-23\n",
      "fDate2015-11-03                        6.322037e-16\n",
      "fDate2015-11-04                        1.792709e-10\n",
      "fDate2015-11-05                        1.903333e-12\n",
      "fDate2015-11-06                        7.828971e-01\n",
      "fDate2015-11-09                        6.008581e-25\n",
      "fDate2015-11-10                        5.557548e-18\n",
      "fDate2015-11-11                        3.680490e-07\n",
      "fDate2015-11-12                        1.199647e-08\n",
      "fDate2015-11-13                        2.113832e-01\n",
      "fDate2015-11-16                        1.176158e-35\n",
      "fDate2015-11-17                        3.215134e-11\n",
      "fDate2015-11-18                        9.407087e-08\n",
      "fDate2015-11-19                        6.776536e-11\n",
      "fDate2015-11-20                        3.951916e-01\n",
      "fDate2015-11-23                        2.581846e-01\n",
      "fDate2015-11-24                        2.338119e-01\n",
      "fDate2015-11-25                        2.039948e-29\n",
      "fDate2015-11-30                        3.051055e-70\n",
      "fDate2015-12-01                        6.550547e-21\n",
      "fDate2015-12-02                        1.190480e-26\n",
      "fDate2015-12-03                        1.335102e-07\n",
      "fDate2015-12-04                        2.197293e-02\n",
      "fDate2015-12-07                        1.407029e-15\n",
      "fDate2015-12-08                        8.600211e-16\n",
      "fDate2015-12-09                        7.684065e-08\n",
      "fDate2015-12-10                        1.752288e-10\n",
      "fDate2015-12-11                        1.020098e-01\n",
      "fDate2015-12-14                        1.008103e-25\n",
      "fDate2015-12-15                        1.753009e-09\n",
      "fDate2015-12-16                        4.879754e-06\n",
      "fDate2015-12-17                        1.513103e-08\n",
      "fDate2015-12-18                        1.264517e-06\n",
      "fDate2016-01-04                       8.428174e-100\n",
      "fDate2016-01-05                        4.948299e-44\n",
      "fDate2016-01-06                        2.863837e-37\n",
      "fDate2016-01-07                        6.181405e-44\n",
      "fDate2016-01-08                        5.748767e-27\n",
      "fDate2016-01-11                        1.002703e-57\n",
      "fDate2016-01-12                        3.045732e-44\n",
      "fDate2016-01-13                        2.227757e-45\n",
      "fDate2016-01-14                        2.820057e-50\n",
      "fDate2016-01-15                        2.506158e-26\n",
      "fDate2016-01-19                        1.185437e-60\n",
      "fDate2016-01-20                        2.046776e-41\n",
      "fDate2016-01-21                        3.885402e-44\n",
      "fDate2016-01-22                        1.868203e-24\n",
      "fDate2016-01-25                        3.610611e-56\n",
      "fDate2016-01-26                        3.020528e-51\n",
      "fDate2016-01-27                        2.220857e-47\n",
      "fDate2016-01-28                        6.714195e-47\n",
      "fDate2016-01-29                        1.012026e-29\n",
      "fDate2016-02-01                        2.121211e-21\n",
      "fDate2016-02-02                        1.052252e-37\n",
      "fDate2016-02-03                        1.238209e-41\n",
      "fDate2016-02-04                        1.914438e-45\n",
      "fDate2016-02-05                        1.561665e-29\n",
      "fDate2016-02-08                        2.051433e-60\n",
      "fDate2016-02-09                        1.049131e-09\n",
      "fDate2016-02-10                        2.967943e-05\n",
      "fDate2016-02-11                        5.993745e-11\n",
      "fDate2016-02-12                        1.796497e-02\n",
      "fDate2016-02-16                        4.310901e-15\n",
      "fDate2016-02-17                        2.013315e-12\n",
      "fDate2016-02-18                        1.617102e-07\n",
      "fDate2016-02-19                        7.139827e-02\n",
      "fDate2016-02-22                        1.137230e-21\n",
      "fDate2016-02-23                        1.043729e-20\n",
      "fDate2016-02-24                        3.098549e-09\n",
      "fDate2016-02-25                        1.193485e-09\n",
      "fDate2016-02-26                        2.633116e-02\n",
      "fDate2016-02-29                        7.184698e-27\n",
      "fDate2016-03-01                        2.222666e-14\n",
      "fDate2016-03-02                        1.323324e-17\n",
      "fDate2016-03-03                        2.014744e-13\n",
      "fDate2016-03-04                        1.860819e-02\n",
      "fDate2016-03-07                        1.562669e-27\n",
      "fDate2016-03-08                        6.300240e-18\n",
      "fDate2016-03-09                        8.850884e-12\n",
      "fDate2016-03-10                        1.890851e-10\n",
      "fDate2016-03-11                        1.193958e-01\n",
      "fDate2016-03-14                        2.735218e-19\n",
      "fDate2016-03-15                        1.454056e-17\n",
      "fDate2016-03-16                        1.974475e-14\n",
      "fDate2016-03-17                        1.400007e-14\n",
      "fDate2016-03-18                        3.724350e-01\n",
      "fDate2016-03-21                        1.403790e-37\n",
      "fDate2016-03-22                        1.221806e-21\n",
      "fDate2016-03-23                        1.192446e-10\n",
      "fDate2016-03-24                        3.899572e-16\n",
      "fDate2016-03-25                        2.714960e-01\n",
      "fDate2016-03-28                        6.661256e-23\n",
      "fDate2016-03-29                        4.443368e-07\n",
      "fDate2016-03-30                        1.864002e-13\n",
      "fDate2016-03-31                        1.347768e-09\n",
      "fDate2016-04-01                        8.787281e-01\n",
      "fDate2016-04-04                        9.853948e-23\n",
      "fDate2016-04-05                        1.272873e-17\n",
      "fDate2016-04-06                        4.988853e-11\n",
      "fDate2016-04-07                        4.678150e-06\n",
      "fDate2016-04-08                        1.134749e-01\n",
      "f_commutes_since_last_ride2            0.000000e+00\n",
      "f_commutes_since_last_ride3            0.000000e+00\n",
      "f_commutes_since_last_ride4            0.000000e+00\n",
      "f_commutes_since_last_ride5            0.000000e+00\n",
      "f_commutes_since_last_ride6            0.000000e+00\n",
      "f_commutes_since_last_ride7            0.000000e+00\n",
      "f_commutes_since_last_ride8            0.000000e+00\n",
      "f_commutes_since_last_ride9            0.000000e+00\n",
      "f_commutes_since_last_ride10           0.000000e+00\n",
      "f_commutes_since_last_ride11           0.000000e+00\n",
      "f_commutes_since_last_ride12           0.000000e+00\n",
      "f_commutes_since_last_ride13           0.000000e+00\n",
      "f_commutes_since_last_ride14           0.000000e+00\n",
      "f_commutes_since_last_ride15           0.000000e+00\n",
      "f_commutes_since_last_ride16           0.000000e+00\n",
      "f_commutes_since_last_ride17           0.000000e+00\n",
      "f_commutes_since_last_ride18           0.000000e+00\n",
      "f_commutes_since_last_ride19           0.000000e+00\n",
      "f_commutes_since_last_ride20           0.000000e+00\n",
      "f_commutes_since_last_ride21           0.000000e+00\n",
      "f_commutes_since_last_ride22           0.000000e+00\n",
      "f_commutes_since_last_ride23           0.000000e+00\n",
      "f_commutes_since_last_ride24           0.000000e+00\n",
      "f_commutes_since_last_ride25           0.000000e+00\n",
      "f_commutes_since_last_ride26           0.000000e+00\n",
      "f_commutes_since_last_ride27           0.000000e+00\n",
      "f_commutes_since_last_ride28           0.000000e+00\n",
      "f_commutes_since_last_ride29           0.000000e+00\n",
      "f_commutes_since_last_ride30           0.000000e+00\n",
      "f_commutes_since_last_ride31           0.000000e+00\n",
      "f_commutes_since_last_ride32           0.000000e+00\n",
      "f_commutes_since_last_ride33           0.000000e+00\n",
      "f_commutes_since_last_ride34           0.000000e+00\n",
      "f_commutes_since_last_ride35           0.000000e+00\n",
      "f_commutes_since_last_ride36           0.000000e+00\n",
      "f_commutes_since_last_ride37           0.000000e+00\n",
      "f_commutes_since_last_ride38           0.000000e+00\n",
      "f_commutes_since_last_ride39           0.000000e+00\n",
      "f_commutes_since_last_ride40           0.000000e+00\n",
      "f_favorite_route2                      1.886693e-59\n",
      "f_favorite_route3                      1.387615e-16\n",
      "f_favorite_route4                      5.008918e-64\n",
      "f_favorite_route5                     2.939275e-131\n",
      "f_favorite_route6                      1.795266e-12\n",
      "f_favorite_route7                      9.062047e-66\n",
      "f_favorite_route8                      3.932341e-04\n",
      "f_favorite_route9                      2.309635e-05\n",
      "f_favorite_route10                     4.383468e-37\n",
      "f_favorite_route11                     2.088482e-01\n",
      "f_favorite_route12                     6.753292e-04\n",
      "f_favorite_route13                     5.774339e-03\n",
      "f_favorite_route14                     2.803443e-21\n",
      "f_favorite_route15                     2.018101e-50\n",
      "f_favorite_route16                     1.067585e-05\n",
      "f_favorite_route17                     9.728067e-12\n",
      "f_favorite_route18                     1.686822e-50\n",
      "f_favorite_route19                     1.521065e-01\n",
      "f_favorite_route20                     3.613398e-28\n",
      "f_favorite_route21                     1.313488e-07\n",
      "imputed_new_buses:single_stop_10_ride  1.874999e-02\n",
      "\n",
      "=------------------------======================\n",
      "Missing coefficients:\n",
      " Is405North_10_ride:I405HOV imputed_new_buses:Is405North_10_ride:I405HOV single_stop_10_ride:Is405North_10_ride:I405HOV\n",
      "\n",
      "Available coefficients:\n",
      "  [1] \"(Intercept)\"                          \n",
      "  [2] \"imputed_new_buses\"                    \n",
      "  [3] \"fDate2015-09-03\"                      \n",
      "  [4] \"fDate2015-09-04\"                      \n",
      "  [5] \"fDate2015-09-08\"                      \n",
      "  [6] \"fDate2015-09-09\"                      \n",
      "  [7] \"fDate2015-09-10\"                      \n",
      "  [8] \"fDate2015-09-11\"                      \n",
      "  [9] \"fDate2015-09-14\"                      \n",
      " [10] \"fDate2015-09-15\"                      \n",
      " [11] \"fDate2015-09-16\"                      \n",
      " [12] \"fDate2015-09-17\"                      \n",
      " [13] \"fDate2015-09-18\"                      \n",
      " [14] \"fDate2015-09-21\"                      \n",
      " [15] \"fDate2015-09-22\"                      \n",
      " [16] \"fDate2015-09-23\"                      \n",
      " [17] \"fDate2015-09-24\"                      \n",
      " [18] \"fDate2015-09-25\"                      \n",
      " [19] \"fDate2015-09-28\"                      \n",
      " [20] \"fDate2015-09-29\"                      \n",
      " [21] \"fDate2015-09-30\"                      \n",
      " [22] \"fDate2015-10-01\"                      \n",
      " [23] \"fDate2015-10-02\"                      \n",
      " [24] \"fDate2015-10-05\"                      \n",
      " [25] \"fDate2015-10-06\"                      \n",
      " [26] \"fDate2015-10-07\"                      \n",
      " [27] \"fDate2015-10-08\"                      \n",
      " [28] \"fDate2015-10-09\"                      \n",
      " [29] \"fDate2015-10-12\"                      \n",
      " [30] \"fDate2015-10-13\"                      \n",
      " [31] \"fDate2015-10-14\"                      \n",
      " [32] \"fDate2015-10-15\"                      \n",
      " [33] \"fDate2015-10-16\"                      \n",
      " [34] \"fDate2015-10-19\"                      \n",
      " [35] \"fDate2015-10-20\"                      \n",
      " [36] \"fDate2015-10-21\"                      \n",
      " [37] \"fDate2015-10-22\"                      \n",
      " [38] \"fDate2015-10-23\"                      \n",
      " [39] \"fDate2015-10-26\"                      \n",
      " [40] \"fDate2015-10-27\"                      \n",
      " [41] \"fDate2015-10-28\"                      \n",
      " [42] \"fDate2015-10-29\"                      \n",
      " [43] \"fDate2015-10-30\"                      \n",
      " [44] \"fDate2015-11-02\"                      \n",
      " [45] \"fDate2015-11-03\"                      \n",
      " [46] \"fDate2015-11-04\"                      \n",
      " [47] \"fDate2015-11-05\"                      \n",
      " [48] \"fDate2015-11-06\"                      \n",
      " [49] \"fDate2015-11-09\"                      \n",
      " [50] \"fDate2015-11-10\"                      \n",
      " [51] \"fDate2015-11-11\"                      \n",
      " [52] \"fDate2015-11-12\"                      \n",
      " [53] \"fDate2015-11-13\"                      \n",
      " [54] \"fDate2015-11-16\"                      \n",
      " [55] \"fDate2015-11-17\"                      \n",
      " [56] \"fDate2015-11-18\"                      \n",
      " [57] \"fDate2015-11-19\"                      \n",
      " [58] \"fDate2015-11-20\"                      \n",
      " [59] \"fDate2015-11-23\"                      \n",
      " [60] \"fDate2015-11-24\"                      \n",
      " [61] \"fDate2015-11-25\"                      \n",
      " [62] \"fDate2015-11-30\"                      \n",
      " [63] \"fDate2015-12-01\"                      \n",
      " [64] \"fDate2015-12-02\"                      \n",
      " [65] \"fDate2015-12-03\"                      \n",
      " [66] \"fDate2015-12-04\"                      \n",
      " [67] \"fDate2015-12-07\"                      \n",
      " [68] \"fDate2015-12-08\"                      \n",
      " [69] \"fDate2015-12-09\"                      \n",
      " [70] \"fDate2015-12-10\"                      \n",
      " [71] \"fDate2015-12-11\"                      \n",
      " [72] \"fDate2015-12-14\"                      \n",
      " [73] \"fDate2015-12-15\"                      \n",
      " [74] \"fDate2015-12-16\"                      \n",
      " [75] \"fDate2015-12-17\"                      \n",
      " [76] \"fDate2015-12-18\"                      \n",
      " [77] \"fDate2016-01-04\"                      \n",
      " [78] \"fDate2016-01-05\"                      \n",
      " [79] \"fDate2016-01-06\"                      \n",
      " [80] \"fDate2016-01-07\"                      \n",
      " [81] \"fDate2016-01-08\"                      \n",
      " [82] \"fDate2016-01-11\"                      \n",
      " [83] \"fDate2016-01-12\"                      \n",
      " [84] \"fDate2016-01-13\"                      \n",
      " [85] \"fDate2016-01-14\"                      \n",
      " [86] \"fDate2016-01-15\"                      \n",
      " [87] \"fDate2016-01-19\"                      \n",
      " [88] \"fDate2016-01-20\"                      \n",
      " [89] \"fDate2016-01-21\"                      \n",
      " [90] \"fDate2016-01-22\"                      \n",
      " [91] \"fDate2016-01-25\"                      \n",
      " [92] \"fDate2016-01-26\"                      \n",
      " [93] \"fDate2016-01-27\"                      \n",
      " [94] \"fDate2016-01-28\"                      \n",
      " [95] \"fDate2016-01-29\"                      \n",
      " [96] \"fDate2016-02-01\"                      \n",
      " [97] \"fDate2016-02-02\"                      \n",
      " [98] \"fDate2016-02-03\"                      \n",
      " [99] \"fDate2016-02-04\"                      \n",
      "[100] \"fDate2016-02-05\"                      \n",
      "[101] \"fDate2016-02-08\"                      \n",
      "[102] \"fDate2016-02-09\"                      \n",
      "[103] \"fDate2016-02-10\"                      \n",
      "[104] \"fDate2016-02-11\"                      \n",
      "[105] \"fDate2016-02-12\"                      \n",
      "[106] \"fDate2016-02-16\"                      \n",
      "[107] \"fDate2016-02-17\"                      \n",
      "[108] \"fDate2016-02-18\"                      \n",
      "[109] \"fDate2016-02-19\"                      \n",
      "[110] \"fDate2016-02-22\"                      \n",
      "[111] \"fDate2016-02-23\"                      \n",
      "[112] \"fDate2016-02-24\"                      \n",
      "[113] \"fDate2016-02-25\"                      \n",
      "[114] \"fDate2016-02-26\"                      \n",
      "[115] \"fDate2016-02-29\"                      \n",
      "[116] \"fDate2016-03-01\"                      \n",
      "[117] \"fDate2016-03-02\"                      \n",
      "[118] \"fDate2016-03-03\"                      \n",
      "[119] \"fDate2016-03-04\"                      \n",
      "[120] \"fDate2016-03-07\"                      \n",
      "[121] \"fDate2016-03-08\"                      \n",
      "[122] \"fDate2016-03-09\"                      \n",
      "[123] \"fDate2016-03-10\"                      \n",
      "[124] \"fDate2016-03-11\"                      \n",
      "[125] \"fDate2016-03-14\"                      \n",
      "[126] \"fDate2016-03-15\"                      \n",
      "[127] \"fDate2016-03-16\"                      \n",
      "[128] \"fDate2016-03-17\"                      \n",
      "[129] \"fDate2016-03-18\"                      \n",
      "[130] \"fDate2016-03-21\"                      \n",
      "[131] \"fDate2016-03-22\"                      \n",
      "[132] \"fDate2016-03-23\"                      \n",
      "[133] \"fDate2016-03-24\"                      \n",
      "[134] \"fDate2016-03-25\"                      \n",
      "[135] \"fDate2016-03-28\"                      \n",
      "[136] \"fDate2016-03-29\"                      \n",
      "[137] \"fDate2016-03-30\"                      \n",
      "[138] \"fDate2016-03-31\"                      \n",
      "[139] \"fDate2016-04-01\"                      \n",
      "[140] \"fDate2016-04-04\"                      \n",
      "[141] \"fDate2016-04-05\"                      \n",
      "[142] \"fDate2016-04-06\"                      \n",
      "[143] \"fDate2016-04-07\"                      \n",
      "[144] \"fDate2016-04-08\"                      \n",
      "[145] \"f_commutes_since_last_ride2\"          \n",
      "[146] \"f_commutes_since_last_ride3\"          \n",
      "[147] \"f_commutes_since_last_ride4\"          \n",
      "[148] \"f_commutes_since_last_ride5\"          \n",
      "[149] \"f_commutes_since_last_ride6\"          \n",
      "[150] \"f_commutes_since_last_ride7\"          \n",
      "[151] \"f_commutes_since_last_ride8\"          \n",
      "[152] \"f_commutes_since_last_ride9\"          \n",
      "[153] \"f_commutes_since_last_ride10\"         \n",
      "[154] \"f_commutes_since_last_ride11\"         \n",
      "[155] \"f_commutes_since_last_ride12\"         \n",
      "[156] \"f_commutes_since_last_ride13\"         \n",
      "[157] \"f_commutes_since_last_ride14\"         \n",
      "[158] \"f_commutes_since_last_ride15\"         \n",
      "[159] \"f_commutes_since_last_ride16\"         \n",
      "[160] \"f_commutes_since_last_ride17\"         \n",
      "[161] \"f_commutes_since_last_ride18\"         \n",
      "[162] \"f_commutes_since_last_ride19\"         \n",
      "[163] \"f_commutes_since_last_ride20\"         \n",
      "[164] \"f_commutes_since_last_ride21\"         \n",
      "[165] \"f_commutes_since_last_ride22\"         \n",
      "[166] \"f_commutes_since_last_ride23\"         \n",
      "[167] \"f_commutes_since_last_ride24\"         \n",
      "[168] \"f_commutes_since_last_ride25\"         \n",
      "[169] \"f_commutes_since_last_ride26\"         \n",
      "[170] \"f_commutes_since_last_ride27\"         \n",
      "[171] \"f_commutes_since_last_ride28\"         \n",
      "[172] \"f_commutes_since_last_ride29\"         \n",
      "[173] \"f_commutes_since_last_ride30\"         \n",
      "[174] \"f_commutes_since_last_ride31\"         \n",
      "[175] \"f_commutes_since_last_ride32\"         \n",
      "[176] \"f_commutes_since_last_ride33\"         \n",
      "[177] \"f_commutes_since_last_ride34\"         \n",
      "[178] \"f_commutes_since_last_ride35\"         \n",
      "[179] \"f_commutes_since_last_ride36\"         \n",
      "[180] \"f_commutes_since_last_ride37\"         \n",
      "[181] \"f_commutes_since_last_ride38\"         \n",
      "[182] \"f_commutes_since_last_ride39\"         \n",
      "[183] \"f_commutes_since_last_ride40\"         \n",
      "[184] \"f_favorite_route2\"                    \n",
      "[185] \"f_favorite_route3\"                    \n",
      "[186] \"f_favorite_route4\"                    \n",
      "[187] \"f_favorite_route5\"                    \n",
      "[188] \"f_favorite_route6\"                    \n",
      "[189] \"f_favorite_route7\"                    \n",
      "[190] \"f_favorite_route8\"                    \n",
      "[191] \"f_favorite_route9\"                    \n",
      "[192] \"f_favorite_route10\"                   \n",
      "[193] \"f_favorite_route11\"                   \n",
      "[194] \"f_favorite_route12\"                   \n",
      "[195] \"f_favorite_route13\"                   \n",
      "[196] \"f_favorite_route14\"                   \n",
      "[197] \"f_favorite_route15\"                   \n",
      "[198] \"f_favorite_route16\"                   \n",
      "[199] \"f_favorite_route17\"                   \n",
      "[200] \"f_favorite_route18\"                   \n",
      "[201] \"f_favorite_route19\"                   \n",
      "[202] \"f_favorite_route20\"                   \n",
      "[203] \"f_favorite_route21\"                   \n",
      "[204] \"imputed_new_buses:single_stop_10_ride\"\n"
     ]
    },
    {
     "ename": "ERROR",
     "evalue": "Error in coef(summary(LM))[predictors, ]: subscript out of bounds\n",
     "output_type": "error",
     "traceback": [
      "Error in coef(summary(LM))[predictors, ]: subscript out of bounds\nTraceback:\n",
      "1. fit_ridership_logit_models(data = commute_ride_data[(!SR520WBHOV) & \n .     (!SR520EBHOV)], predictors = c(\"imputed_new_buses\", \"imputed_new_buses:single_stop_10_ride\", \n .     \"Is405North_10_ride:I405HOV\", \"imputed_new_buses:Is405North_10_ride:I405HOV\", \n .     \"single_stop_10_ride:Is405North_10_ride:I405HOV\"), adjust_for = c(\"imputed_new_buses + fDate\", \n .     \"f_commutes_since_last_ride\", \"f_favorite_route\"), model = 4, \n .     granularity = \"rider/date/commute\")",
      "2. tryCatch({\n .     print(coef(summary(LM))[predictors, ])\n . }, error = function(err) {\n .     model_coef = dimnames(coef(summary(LM)))[[1]]\n .     cat(\"\\n=------------------------======================\\n\")\n .     print(FMLA)\n .     print(coef(summary(LM)))\n .     cat(\"\\n=------------------------======================\\n\")\n .     cat(\"Missing coefficients:\\n\", predictors[!predictors %in% \n .         model_coef])\n .     cat(\"\\n\\nAvailable coefficients:\\n\")\n .     print(model_coef)\n .     stop(err)\n . })   # at line 74-88 of file <text>",
      "3. tryCatchList(expr, classes, parentenv, handlers)",
      "4. tryCatchOne(expr, names, parentenv, handlers[[1L]])",
      "5. value[[3L]](cond)"
     ]
    }
   ],
   "source": [
    "(T4_M4 = fit_ridership_logit_models(data = commute_ride_data[(!SR520WBHOV) &  (!SR520EBHOV)],\n",
    "                            predictors=c(\n",
    "                                        \"imputed_new_buses\",\n",
    "                                        \"imputed_new_buses:single_stop_10_ride\",\n",
    "                                        \"Is405North_10_ride:I405HOV\",\n",
    "                                        \"imputed_new_buses:Is405North_10_ride:I405HOV\",\n",
    "                                        \"single_stop_10_ride:Is405North_10_ride:I405HOV\"\n",
    "                                        ),\n",
    "                            adjust_for=c(\"imputed_new_buses + fDate\",\n",
    "                                            \"f_commutes_since_last_ride\",\n",
    "                                            \"f_favorite_route\"),\n",
    "                            model=4,\n",
    "                            granularity=\"rider/date/commute\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "(T4_M5 = fit_ridership_logit_models(data = commute_ride_data[(!SR520WBHOV) &  (!SR520EBHOV)],\n",
    "                            predictors=c(\n",
    "                                        \"imputed_new_buses\",\n",
    "                                        \"imputed_new_buses:single_stop_10_ride\",\n",
    "                                        \"Is405North_10_ride:I405HOV\",\n",
    "                                        \"imputed_new_buses:Is405North_10_ride:I405HOV\",\n",
    "                                        \"single_stop_10_ride:Is405North_10_ride:I405HOV\",\n",
    "                                        \"imputed_new_buses:single_stop_10_ride:Is405North_10_ride:I405HOV\"\n",
    "                                        ),\n",
    "                            adjust_for=c(\"imputed_new_buses + fDate\",\n",
    "                                            \"f_commutes_since_last_ride\",\n",
    "                                            \"f_favorite_route\"),\n",
    "                            model=5,\n",
    "                            granularity=\"rider/date/commute\"))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Table 4 Summary Statistics"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "(TABLE_4 <- rbind(T4_M1,T4_M2,T4_M3,T4_M4,T4_M5))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "2"
      ],
      "text/latex": [
       "2"
      ],
      "text/markdown": [
       "2"
      ],
      "text/plain": [
       "[1] 2"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "1 + 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table>\n",
       "<thead><tr><th></th><th scope=col>used</th><th scope=col>(Mb)</th><th scope=col>gc trigger</th><th scope=col>(Mb)</th><th scope=col>max used</th><th scope=col>(Mb)</th></tr></thead>\n",
       "<tbody>\n",
       "\t<tr><th scope=row>Ncells</th><td>  666084  </td><td> 35.6     </td><td>   2451540</td><td>  131     </td><td>  11278674</td><td>  602.4   </td></tr>\n",
       "\t<tr><th scope=row>Vcells</th><td>73966111  </td><td>564.4     </td><td>1605759336</td><td>12251     </td><td>3340642637</td><td>25487.1   </td></tr>\n",
       "</tbody>\n",
       "</table>\n"
      ],
      "text/latex": [
       "\\begin{tabular}{r|llllll}\n",
       "  & used & (Mb) & gc trigger & (Mb) & max used & (Mb)\\\\\n",
       "\\hline\n",
       "\tNcells &   666084   &  35.6      &    2451540 &   131      &   11278674 &   602.4   \\\\\n",
       "\tVcells & 73966111   & 564.4      & 1605759336 & 12251      & 3340642637 & 25487.1   \\\\\n",
       "\\end{tabular}\n"
      ],
      "text/markdown": [
       "\n",
       "| <!--/--> | used | (Mb) | gc trigger | (Mb) | max used | (Mb) |\n",
       "|---|---|---|---|---|---|---|\n",
       "| Ncells |   666084   |  35.6      |    2451540 |   131      |   11278674 |   602.4    |\n",
       "| Vcells | 73966111   | 564.4      | 1605759336 | 12251      | 3340642637 | 25487.1    |\n",
       "\n"
      ],
      "text/plain": [
       "       used     (Mb)  gc trigger (Mb)  max used   (Mb)   \n",
       "Ncells   666084  35.6    2451540   131   11278674   602.4\n",
       "Vcells 73966111 564.4 1605759336 12251 3340642637 25487.1"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "gc()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "R",
   "language": "R",
   "name": "ir"
  },
  "language_info": {
   "codemirror_mode": "r",
   "file_extension": ".r",
   "mimetype": "text/x-r-source",
   "name": "R",
   "pygments_lexer": "r",
   "version": "3.5.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
